asp.net-core - 如何在 ASP.NET Core 的 OpenIdConnectOptions 上设置 redirect_uri 参数

标签 asp.net-core openid-connect

我正在尝试使用 OpenId 将 ASP.NET 应用程序连接到 Salesforce,目前这是我迄今为止的连接代码。我想我得到了除了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 不是要传递的有效参数。正确的设置方法是什么?

最佳答案

您需要为OnRedirectToIdentityProvider设置事件监听

就你的情况而言:

x.Events.OnRedirectToIdentityProvider = async n =>
{
    n.ProtocolMessage.RedirectUri = <Redirect URI string>;
    await Task.FromResult(0);
}

关于asp.net-core - 如何在 ASP.NET Core 的 OpenIdConnectOptions 上设置 redirect_uri 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35976870/

相关文章:

asp.net-core - ASP.NET Core 1.0 是否支持 ApiExplorer,如何使用它?

sql-server - VS Code 和 macOS 错误 : "LocalDB is not supported on this platform"

c# - 在 ASP.NET Core Razor Pages 中重命名页面/共享目录

amazon-web-services - 如何从 ALB OIDC session 注销?

asp.net-core - ASP.Net Core Razor 页面中的 Bootstrap Multiselect 在单击时不显示下拉列表

c# - 如何将 OData 与 ASP.net Core 正确集成

c# - ASP.Net Core 1.1 MVC 应用程序中的 401 未经 IdentityServer3 授权

asp.net - OpenId Connect,让不记名 token 客户端在 MVC 登录后调用 WebApi 的最佳方法?

既然 Google 已弃用其 OpenID2 提供商,那么 OpenID Connect 授权又如何?

Azure AD B2C 开放 ID 连接与 OAuth 2.0