gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 10:45:02 27 4
gpt4 key购买 nike

我正在尝试使用 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com