将多个客户端添加到Spring OAuth2身份验证服务器
2022-09-02 12:42:12
我有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);
我可以使用第一个客户端获取访问令牌,但是当尝试使用第二个客户端获取访问令牌时,我收到此错误:
{
"timestamp": 1456822249638,
"status": 401,
"error": "Unauthorized",
"message": "Bad credentials",
"path": "/oauth/token"
}
是否可以添加多个客户端以及如何执行此操作?Allso,如何从数据库中读取客户端?