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

What's going on in Spring Boot OAuth2 `AbstractTokenGranter.validateGrantType()` method?

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

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

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

authorized_grant_types = `password, authorization_code, client_credentials, refresh_token`

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

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

您似乎在使用 RDBMS。当您在 oauth_client_details table 中插入客户记录时,请确保 authorized_grant_types 列的值中没有 space。

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

'password,client_credentials,refresh_token'