Loi*_*Tri 5 java authorization spring-boot spring-security-oauth2 spring-oauth2
我正在使用 spring 授权服务器,但我无法获取令牌。这是我的代码和示例。请帮助我知道正确的请求
@Bean
public RegisteredClientRepository registeredClientRepository() {
RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString())
.clientId("client")
.clientSecret("secret")
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC)
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_JWT)
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST)
.clientAuthenticationMethod(ClientAuthenticationMethod.PRIVATE_KEY_JWT)
.authorizationGrantType(AuthorizationGrantType.PASSWORD)
.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)
.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
.authorizationGrantType(AuthorizationGrantType.JWT_BEARER)
.clientSettings(clientSettings -> clientSettings.requireUserConsent(true))
.build();
return new InMemoryRegisteredClientRepository(registeredClient);
}
Run Code Online (Sandbox Code Playgroud)
这是我对基本身份验证客户端/秘密的请求
curl --location --request POST 'http://localhost:9000/oauth2/token'
--header '授权:基本 Y2xpZW50OnNlY3JldA=='
--header '内容类型:application/x-www-form-urlencoded'
--header 'Cookie: JSESSIONID=557C0348994EFC10DB8E7F06C2FDFF21'
--data-urlencode 'grant_type=client_credentials'
响应 401:
{“错误”:“invalid_client”}
您可以尝试升级spring-security-oauth2-authorization-server到较新的版本0.2.0
我遇到了同样的问题client_secret_post,但升级版本对我有用。
| 归档时间: |
|
| 查看次数: |
1819 次 |
| 最近记录: |