spring-security-oauth2-authorization-server:0.1.1获取令牌错误无效\u客户端

h6my8fg2  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(287)

我正在使用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);
}

这是我对基本身份验证客户端/密码的请求
curl--location--request post'http://localhost:9000/oauth2/token'
--标题“授权:基本y2xpzw50onnly3jlda==”
--标题“内容类型:应用程序/x-www-form-urlencoded”
--标题“cookie:jsessionid=557c0348994efc10db8e7f06c2fdff21”
--数据urlencode“授予\类型=客户端\凭据”
答复401:
{“错误”:“无效的_客户端”}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题