Spring 字符串oauth 2资源所有者密码流--用户名和客户端id已交换

Spring 字符串oauth 2资源所有者密码流--用户名和客户端id已交换,spring,oauth,Spring,Oauth,我尝试按照SpringSparkr2示例设置OAuth2服务器。我将其修改为使用数据库userDetailsService。当我尝试用curl交换带有密码的令牌时,如下所示: curl -X POST -d "client_id=client1&client_secret=123456&grant_type=password&username=user1&password=abc" http://mymachine:8080/oauth/token 加载用户fi

我尝试按照SpringSparkr2示例设置OAuth2服务器。我将其修改为使用数据库userDetailsService。当我尝试用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(字符串,用户名密码AuthenticationToken)行:101
DaoAuthenticationProvider(AbstractUserDetailsAuthenticationProvider)。身份验证(身份验证)行:132 ProviderManager.Authentication(身份验证)行:156
ClientCredentialsTokenEndpointFilter.attemptAuthentication(HttpServletRequest,HttpServletResponse)行:109
ClientCredentialsTokenEndpointFilter(AbstractAuthenticationProcessingFilter).doFilter(ServletRequest、ServletResponse、FilterChain)行:211

我试着在Sparker2上卷曲

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

同样,“我的受信任客户机”作为用户名传递。但是我还没有弄明白为什么它可以正确地为Sparkr2获取令牌。

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