dpl*_*esa 16 java spring spring-security oauth-2.0 spring-security-oauth2
我有Spring OAuth授权服务器,我想添加对多个客户端(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);
Run Code Online (Sandbox Code Playgroud)
我可以使用第一个客户端获取访问令牌,但在尝试使用第二个客户端获取访问令牌时出现此错误:
{
"timestamp": 1456822249638,
"status": 401,
"error": "Unauthorized",
"message": "Bad credentials",
"path": "/oauth/token"
}
Run Code Online (Sandbox Code Playgroud)
是否可以添加多个客户端以及如何执行此操作?另外,如何从数据库中读取客户端?
Ali*_*ani 19
不要使用多个inMemory构建器,而是withClient在一个内部连接多个构建器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");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5577 次 |
| 最近记录: |