2016-03-13 25 views
2

我试图使用OpenId将ASP.NET应用程序连接到Salesforce,目前这是我迄今为止的连接代码。我想我得到了除redirect_uri参数外的所有内容,它必须完全匹配另一端的值。如何在ASP.NET Core的OpenIdConnectOptions上设置redirect_uri参数

app.UseCookieAuthentication(x => 
     { 
      x.AutomaticAuthenticate = true; 
      x.CookieName = "MyApp"; 
      x.CookieSecure = CookieSecureOption.Always; 
      x.AuthenticationScheme = "Cookies"; 

     }); 

     JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary<string, string>(); 


     app.UseOpenIdConnectAuthentication(x => 
     { 
      x.AutomaticAuthenticate = true; 
      x.Authority = "https://login.salesforce.com"; 
      x.ClientId = "CLIENT_ID_HERE"; 
      x.ResponseType = "code"; 
      x.AuthenticationScheme = "oidc"; 
      x.CallbackPath = new PathString("/services/oauth2/success"); 
      //x.RedirectUri = "https://login.salesforce.com/services/oauth2/success"; 
      x.Scope.Add("openid"); 
      x.Scope.Add("profile"); 
      x.Scope.Add("email");     
     }); 

但是RedirectUri不是一个有效的参数传递。什么是正确的方式来设置它?

+1

对于OIDC,添加'x.SignInScheme =“Cookie”'并移除'x.AutomaticAuthenticate'。 – Tratcher

回答

5

redirect_uri会自动使用从当前请求中提取的方案,主机,端口和路径以及您指定的CallbackPath为您计算。

x.RedirectUri = "https://login.salesforce.com/services/oauth2/success"看起来高度可疑(除非您为Salesforce工作):不要忘记这是用户代理将在身份验证流程完成时重定向到的回调URL,而不是身份提供商的授权端点。

所以在你的情况下,用户将被重定向到http(s)://yourdomain.com/services/oauth2/success。它是您在Salesforce选项中注册的地址吗?

相关问题