【发布时间】:2018-10-27 08:08:39
【问题描述】:
我的 identityserver4 客户端如下所示:
new Client {
ClientId = "openIdConnectClient",
ClientName = "Example Implicit Client Application",
//AllowedGrantTypes = GrantTypes.Implicit,
AllowedGrantTypes = GrantTypes.ClientCredentials,
ClientSecrets =
{
new Secret("secret".Sha256())
},
AllowOfflineAccess = true,
AllowAccessTokensViaBrowser = true,
AccessTokenLifetime = 30,
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
"role",
"customAPI.write"
},
RedirectUris = new List<string> {"http://localhost:8080/callback"},
PostLogoutRedirectUris = new List<string> {"https://localhost:44330"},
AllowedCorsOrigins = new List<string>
{
"http://127.0.0.1:8080",
"http://localhost:8080",
"*"
},
}
在 react 应用程序中,我的 userManager 类如下所示:
import { createUserManager } from 'redux-oidc';
const userManagerConfig = {
client_id: 'openIdConnectClient',
redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/callback`,
//response_type: 'code id_token token',
response_type: 'token id_token',
scope: 'openid profile email role',
authority: 'http://localhost:50604',
silent_redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/silent_renew.html`,
automaticSilentRenew: true,
filterProtocolClaims: true,
loadUserInfo: true,
};
const userManager = createUserManager(userManagerConfig);
export default userManager;
问题是:当我尝试从 redux-oidc 示例应用程序调用我的 identityserver4 时。我收到以下错误:
客户端请求访问令牌 - 但客户端未配置为通过浏览器接收访问令牌
我希望你能理解这个问题。请有人帮我解决这个问题。我在下面提供了此示例应用程序的链接。
【问题讨论】:
-
没关系,我发现了问题,数据库中有一个名为 dbo.Clients 的表,它是由 identityServer4 创建的。您必须将 AllowAccessTokenViaBrowser 列值更改为 true
标签: redux react-redux identityserver4 redux-thunk redux-saga