model-view-controller - 身份服务器 4:为什么我收到未授权客户端?
问题描述
这是我的 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);
}
}
});
我可以访问身份服务器。我收到一条消息
抱歉,出现错误:未授权_客户端无效的重定向_uri
我已将 redirectUri 添加到与上面显示的代码匹配的 ClientRedirectUris 表中。是否还有其他我忘记添加或设置的区域。
解决方案
您必须确保重定向 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
}
}
确保与客户端“ http://localhost:62419/signin-oidc ”RedirectUris
中设置的重定向 url 匹配
推荐阅读
- mysql - SQL for WP 删除具有多个元键和评论的用户
- java - 泽西 MessageBodyProviderNotFoundException
- java - 如何检测丢失的 MySQL 服务器但仍允许长时间运行的查询
- java - 尝试读取 txt 文件并将它们转换为具有不同原语的对象
- python - 如何在 DJango 中激活虚拟环境
- c# - 从父对象名称不固定的 JSON 字符串访问属性
- abap - 将线轴转换为文本格式
- github - 是否可以在 Github 上的特定文件中搜索代码片段
- java - 在添加行时编辑 TableView 的单元格不起作用
- php - Laravel 如何使用 json_decode 转换模型和集合?