gpt4 book ai didi

model-view-controller - 身份服务器 4 : Why i receive unauthorized_client?

转载 作者:行者123 更新时间:2023-12-02 00:58:09 25 4
gpt4 key购买 nike

这是我的 mvc 与身份服务器连接的初始设置。

 app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
SignInAsAuthenticationType = "Cookies",
Authority = "http://identity.azurewebsites.net",
RedirectUri = "http://localhost:62419/signin-oidc",
PostLogoutRedirectUri = "http://localhost:62419/signout-callback-oidc",
ClientId = "mvc",
ResponseType = "id_token",
Scope = "openid profile",
UseTokenLifetime = false,
RequireHttpsMetadata = false,
Notifications = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenValidated = (context) =>
{
var identity = context.AuthenticationTicket.Identity;
var name = identity.Claims.FirstOrDefault(c => c.Type == identity.NameClaimType)?.Value;

return Task.FromResult(0);
}
}
});

我可以访问身份服务器。我收到一条消息

Sorry, there was an error : unauthorized_client Invalid redirect_uri



我已将 redirectUri 添加到与上面显示的代码匹配的 ClientRedirectUris 表中。有没有我忘记添加或设置的其他区域。

请求网址: http://identity.azurewebsites.net/home/error?errorId=CfDJ8BPcf2qEDmRMt0TtYfAIujdUrTeIfqktT2TIcVFNomo6u6QFAROi-gEI2wXHP8kbmmiSYIK1aRV1nL-h6tFY_KeZabkMhIzy-V_0vvo2-hUFfj6I66qJWSjPiRhSYmGZa_-kYlULMb8a1Bz6UQ9UV5L6VdLscQRhScCpnOYpM6Ku84KM_S-4eZXrAX13EaVhqjxhpNhD8jIU9kJkjAn1t6sLVGrfZSEM0tAOGkTXFvBzuoucYURIFhZPJPGjVuJuRegrS2vsLPALHJCv3MLrW9ImudDeCkgf9VhAHwrRLfP3TB_7i4OvEffZwhuDuCSoyQ

最佳答案

您必须确保重定向 url 与 IdentityServer 中客户端配置中的重定向 url 匹配。例如

    new Client
{
ClientId = "mvc",
ClientName = "MVC Client",
AllowedGrantTypes = GrantTypes.Implicit,

// where to redirect to after login
RedirectUris = { "http://localhost:62419/signin-oidc" },

// where to redirect to after logout
PostLogoutRedirectUris = { "http://localhost:62419/signout-callback-oidc" },

AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile
}
}

确保 RedirectUris匹配您的客户端中设置的重定向 url ' http://localhost:62419/signin-oidc '

关于model-view-controller - 身份服务器 4 : Why i receive unauthorized_client?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52655664/

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