我有Spring OAuth授权服务器,我想增加对一个以上client(id)的支持。我这样配置客户端:
clients
.inMemory().withClient(client).secret(clientSecret)
.resourceIds(resourceId)
.authorizedGrantTypes("client_credentials", "password", "refresh_token", "implicit", "authorization_code")
.authorities("ROLE_USER")
.scopes("read", "write")
.autoApprove(true)
.and()
.inMemory().withClient("acme").secret("acmesecret")
.resourceIds(resourceId)
.authorizedGrantTypes("client_credentials", "password", "refresh_token", "implicit", "authorization_code")
.authorities("ROLE_USER_ACME")
.scopes("read", "write")
.autoApprove(true);
我可以使用第一个客户端获取访问令牌,但是尝试使用第二个客户端获取访问令牌时出现此错误:
{
"timestamp": 1456822249638,
"status": 401,
"error": "Unauthorized",
"message": "Bad credentials",
"path": "/oauth/token"
}
是否可以添加多个客户端,以及如何添加?那么,如何从数据库读取客户端?
不要使用多个inMemory
构建器,而是将多个withClient
s 连接在一个内部inMemory
:
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient("first")
.secret("secret")
.scopes("read")
.authorizedGrantTypes("password")
.and()
.withClient("sec")
.secret("secret")
.scopes("read")
.authorizedGrantTypes("password");
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句