2

我尝试按照 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() 失败,当我查看代码时,它使用客户端 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

相同,“我的信任客户端”作为用户名传递。但我还没有弄清楚为什么它会为 sparklr2 正确取回令牌。

4

1 回答 1

0

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

于 2013-09-08T03:06:21.287 回答