gpt4 book ai didi

angular - 身份服务器 4 : Invalid grant type for client: authorization_code

转载 作者:行者123 更新时间:2023-12-04 13:15:00 24 4
gpt4 key购买 nike

我正在尝试使用身份服务器授权我的 angular 客户端。以下是我的 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'
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
}
它工作正常。但是当我将相同的客户端设置移动到数据库时,它给了我 客户端的授权类型无效 .
以下是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
客户端的数据库数据如下。
enter image description here
和grantType。
enter image description here

最佳答案

我已经想通了。 GrantType我在数据库中提到是错误的。
从内存中获取客户端时,我正在编写以下代码。即来自 appsettings.json文件

 new Client
{
-------
-------
AllowedGrantTypes = GrantTypes.Code,
--------
--------
}
后来当我将此信息移至数据库时,我错误地使用了相同的 grantTypeCode ,这是错误的。它应该定义为 authorization_code .
所以通过改变 GrantType在来自 Code 的数据库中至 authorization_code .修复了我的问题。

关于angular - 身份服务器 4 : Invalid grant type for client: authorization_code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61385126/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com