Spring security 将客户端id配置为密码授予类型的必需参数

Spring security 将客户端id配置为密码授予类型的必需参数,spring-security,spring-security-oauth2,Spring Security,Spring Security Oauth2,将客户id设为密码授权类型的强制参数的正确方法是什么? 使用此请求,我希望将client_id设置为强制值,并让OAuth2框架将其与返回到方法loadClientByClientId curl --location --request POST 'http://localhost:8080/engine/oauth/token' \ --header 'Authorization: Basic YWRtaW46cXdlcnR5' \ --header 'Content-Type: applic

客户id
设为
密码
授权类型的强制参数的正确方法是什么? 使用此请求,我希望将client_id设置为强制值,并让OAuth2框架将其与返回到方法
loadClientByClientId

curl --location --request POST 'http://localhost:8080/engine/oauth/token' \
--header 'Authorization: Basic YWRtaW46cXdlcnR5' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=qwerty' \
--data-urlencode 'client_id=some_value' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'scope=read_profile'

实现这一点的最佳方法是什么?

您可以尝试从

确保客户端已请求一组有效的作用域

它可以访问
TokenRequest.getRequestParameters()

编辑 另请参见文档以了解详细信息

客户端必须经过身份验证(…)才能访问此端点,并且客户端id是从身份验证令牌中提取的。(……)


为什么您认为
客户端id
不是强制性的?是的,我同意,我不知道Oauth2的任何一个实现中clientId不是强制性的。这样很好,因为这没有任何意义