Bil*_*lal 6 asp.net-core identityserver4 angular
我正在尝试使用身份服务器授权我的角度客户端。以下是我的角度客户端的设置。
authority: 'http://localhost:5000',
client_id: 'clientid',
redirect_uri: 'https://localhost:44384/auth-callback',
post_logout_redirect_uri: 'https://localhost:44384/',
response_type: "code",
scope: "openid profile",
filterProtocolClaims: true,
loadUserInfo: true,
automaticSilentRenew: true,
silent_redirect_uri: 'http://localhost:44384/silent-refresh.html'
Run Code Online (Sandbox Code Playgroud)
类似的客户端在IdentityServer端注册。
new Client
{
ClientId = "clientid",
AllowedScopes = { "openid", "profile" },
AllowedGrantTypes = GrantTypes.Code,
RequirePkce = true,
RequireClientSecret = false,
AllowAccessTokensViaBrowser = true,
AllowOfflineAccess = false,
AccessTokenLifetime = 3600,
RedirectUris={"https://localhost:44384/auth-callback" },
PostLogoutRedirectUris= {"https://localhost:44384/" },
RequireConsent= false
}
Run Code Online (Sandbox Code Playgroud)
并且运行良好。但是当我将相同的客户端设置移至数据库时,它给了我 Invalid grant type for client。
以下是VS日志
[15:15:56 Debug] IdentityServer4.EntityFramework.Stores.ClientStore
clientid found in database: True
[15:15:56 Debug] IdentityServer4.Stores.ValidatingClientStore
client configuration validation for client clientid succeeded.
[15:15:56 Debug] IdentityServer4.Validation.AuthorizeRequestValidator
Checking for PKCE parameters
[15:15:56 Error] IdentityServer4.Validation.AuthorizeRequestValidator: Invalid grant type for client: authorization_code
Run Code Online (Sandbox Code Playgroud)
客户端的数据库数据如下。
和 grantType。
我已经想通了。我GrantType在数据库中提到的错误。
当我从记忆中获取客户时,我正在编写以下代码。即来自appsettings.json文件
new Client
{
-------
-------
AllowedGrantTypes = GrantTypes.Code,
--------
--------
}
Run Code Online (Sandbox Code Playgroud)
后来当我将此信息移至数据库时,我错误地使用了相同的grantTypeie Code,这是错误的。它应该像这样定义authorization_code。
因此,通过将GrantType数据库从更改Code为authorization_code. 解决了我的问题。
| 归档时间: |
|
| 查看次数: |
7114 次 |
| 最近记录: |