gpt4 book ai didi

java - Spring Boot OAuth2 `AbstractTokenGranter.validateGrantType()` 方法中发生了什么?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:07:49 26 4
gpt4 key购买 nike

我正在使用 OAuth2 保护 Spring Cloud/Spring Boot 微服务,所有这些似乎都很好地连接在授权服务器中。但是,当我通过 postman 向 /oauth/token 发送 POST 请求以使用 grant_type = client_credentials 获取访问 token 时,我得到以下响应:

{
"error": "invalid_client",
"error_description": "Unauthorized grant type: client_credentials"
}

然而,在注册 OAuth 客户端的 oauth_client_details 数据库表中,我对发出此请求的当前客户端进行了以下设置;

authorized_grant_types = `password, authorization_code, client_credentials, refresh_token`

所以我冒昧地调试了 Spring Boot 的整个 oauth 流程,发现 AbstractTokenGranter.validateGrantType(String grantType, ClientDetails clientDetails) 方法中发生了一些非常有趣的事情。见下图;

enter image description here

所以我想了解这里可能发生的事情,因为这对我来说几乎是深不可测的。

最佳答案

看起来您正在使用 RDBMS。当您在 oauth_client_details 表中插入客户记录时,请确保 authorized_grant_types 列的值中没有空格。

值应该是这样的(逗号后没有空格):

'password,client_credentials,refresh_token'

关于java - Spring Boot OAuth2 `AbstractTokenGranter.validateGrantType()` 方法中发生了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51930058/

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