我的Identity Server在我收到了username_client错误后的几周内运行良好,我不知道为什么。
http://localhost:5001中的Identity Server主机
Angular从http://localhost:4200中的.Net Core项目开始
确切的错误是:
对不起,出现错误:unauthorized_client
未知客户端或未启用客户端
在Identity Server中,我的客户端定义如下:
var clients = new List<Client>
{
new Client
{
ClientId = "app.spa.client",
ClientName = "Client Application",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RequireConsent = false,
RedirectUris =
{
"http://localhost:4200/assets/oidc-login-redirect.html",
"http://localhost:4200/assets/silent-redirect.html"
},
PostLogoutRedirectUris = { "http://localhost:4200/?postLogout=true" },
AllowedCorsOrigins = new[] { "http://localhost:4200/" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"webapi"
},
IdentityTokenLifetime = 120,
AccessTokenLifetime = 120
}
};
在Angular项目中,我从 oidc-client 使用,我的配置如下:
var config = {
authority: "http://localhost:5001/",
client_id: "app.spa.client",
redirect_uri: `http://localhost:4200/assets/oidc-login-redirect.html`,
scope: "openid profile webapi",
response_type: "id_token token",
post_logout_redirect_uri: `http://localhost:4200/?postLogout=true`,
userStore: new WebStorageStateStore({ store: window.localStorage }),
automaticSilentRenew: true,
silent_redirect_uri: `http://localhost:4200/assets/silent-redirect.html`
};
您曾经遇到此错误吗?
如何找到此错误的更多详细信息?
答案 0 :(得分:0)
实际上,我发现了问题,身份服务中的IdentityServer4软件包从版本2.4.0更新到了2.5.0,但是我无法解决此问题。
最终,我被迫降级到2.4.0版本,问题解决了。
有什么想法可以解决IdentityServer4 2.5.0版中的此问题?