【发布时间】:2021-06-29 22:54:10
【问题描述】:
我有一个在 .NET 5 上运行的 Identity Server 4 以及一个使用 oidc-client.js 库的简单 JS SPA 客户端
问题是我无法让我的身份服务器使用隐式身份验证。 我的 SPA 客户端在 https://localhost:44334 上运行,Identity Server 在 https://localhost:5005 上运行
当我点击登录时,我正在尝试使用 oidc-client.js 从 IdentityServer 获取令牌
var config = {
authority: "https://localhost:5005",
client_id: "react-client",
redirect_uri: "https://localhost:44334/callback.html",
response_type: "id_token token",
scope: "openid profile Api1",
post_logout_redirect_uri: "https://localhost:44334/index.html",
};
var mgr = new Oidc.UserManager(config);
mgr.getUser().then(function (user) {
if (user) {
log("User logged in", user.profile);
}
else {
log("User not logged in");
}
});
function login() {
mgr.signinRedirect();
}
这是我在 Identity Server 上的客户端配置
return new IdentityServer4.Models.Client
{
ClientId = "react-client",
ClientName = "React Client",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris = { "https://localhost:44334/callback.html" },
PostLogoutRedirectUris = { "https://localhost:44334/index.html" },
AllowedCorsOrigins = { "https://localhost:44334" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"Api1"
}
};
现在的问题是,当我单击登录按钮时,浏览器会重定向到 IdentityServer,但随后会显示此错误。
我做错了什么?
【问题讨论】:
标签: c# .net asp.net-core oauth identityserver4