String oauth 2资源所有者密码流 - 交换用户名和客户端ID

时间:2013-09-06 23:18:56

标签: spring oauth

我尝试按照spring sparklr2示例设置OAuth 2服务器。我修改它以使用数据库userDetailsS​​ervice。当我尝试用密码与curl交换令牌时,如下所示:

curl -X POST -d "client_id=client1&client_secret=123456&grant_type=password&username=user1&password=abc" http://mymachine:8080/oauth/token

加载用户findByUsername()失败,当我查看代码时,它使用client-id(在我的情况下是'client1')作为用户名。 调用堆栈是: DaoAuthenticationProvider.retrieveUser(String,UsernamePasswordAuthenticationToken)行:101
DaoAuthenticationProvider(AbstractUserDetailsAuthenticationProvider).authenticate(Authentication)行:132 ProviderManager.authenticate(Authentication)行:156
ClientCredentialsTokenEndpointFilter.attemptAuthentication(HttpServletRequest,HttpServletResponse)行:109
ClientCredentialsTokenEndpointFilter(AbstractAuthenticationProcessingFilter).doFilter(ServletRequest,ServletResponse,FilterChain)行:211

我在sparklr2上尝试过curl,

curl -X POST -d "client_id=my-trusted-client&grant_type=password&username=marissa&password=koala" http://mymachine:8080/sparklr2/oauth/token

它是相同的,'my-trusted-client'作为用户名传递。但是我还没弄清楚为什么它会为sparklr2正确地恢复令牌。

1 个答案:

答案 0 :(得分:0)

通过将spring-security-oauth2版本从1.9.5.RELEASE更改为1.1.0.BUILD-SNAPSHOT来解决。