美文网首页
spring boot Oauth2 refresh_token

spring boot Oauth2 refresh_token

作者: 碧波之心 | 来源:发表于2018-06-26 16:03 被阅读122次

今天在测试refresh_token的时候发现报了UserDetailsService is required错误。当时一脸懵逼。权限认证的代码没有变化过呢。怎么就会出问题了呢。想来应该是spring boot版本的问题了,最新项目的spring boot 升级过版本。遇到问题就解决它吧。
本来以为这个用户认证的事情应该是在AuthorizationServerConfigurerAdapter的配置文件中的事情,而正好在用户认证中没有使用UserDetailsService的实现。坑啊!!!我把UserDetailsService 的实现配置到AuthenticationManagerBuilder中,并没有解决问题。经过各种尝试,还写DEMO尝试。问题一直存在。
静下以来,再认认真真的把异常描述看了一遍。

2018-06-26 15:57:54.625  INFO 134740 --- [  XNIO-2 task-2] o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error: IllegalStateException, UserDetailsService is required.

发现是endpoint.TokenEndpoint处报异常。难道新版的需要在AuthorizationServerEndpointsConfigurer中配上UserDetailsService?

@Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        endpoints
            .authenticationManager(this.authenticationManager)
            .tokenStore(tokenStore)
            .userDetailsService(customUserDetailsService);
    }

竟然解决了。

相关文章

网友评论

      本文标题:spring boot Oauth2 refresh_token

      本文链接:https://www.haomeiwen.com/subject/jglmyftx.html