【发布时间】:2015-11-02 15:23:27
【问题描述】:
我在 spring 中配置了一个 auth-server
clients
.inMemory()
.withClient("my-web-app")
.secret("my-web-app-secret")
.authorizedGrantTypes(//
"authorization_code",//
"refresh_token",//
"password"//
).scopes("openid")
现在我想为 webapp 开发一个命令行应用程序。因此,我需要使用单独的客户端 ID 和密码注册另外一个客户端。 我做过这样的事情
.and()
.inMemory()
.withClient("my-cli")
.secret("my-cli-secret")
.authorizedGrantTypes("authorization_code","client_credentials")
.scopes("read","write","trust").authorities("ROLE_USER");
我想要实现的是只需提供用户名/密码,客户端应用程序应该能够从身份验证服务器获取身份验证令牌。
我尝试并理解的是我应该使用资源所有者密码授予。在此之后我必须使用弹簧 Oauth2restTemplate 。 此配置中的问题是当我点击 tokenuri 时,我得到了
{
error: "unauthorized"
error_description: "Full authentication is required to access this resource"
}
每次都是匿名用户。
【问题讨论】:
-
在启用包的调试级别后添加堆栈跟踪:
org.springframework.*
标签: spring authentication spring-security oauth-2.0 resttemplate