Handling error: IllegalStateException, UserDetailsService is required.

在学习spring.sercurity.oauth2时,发现调用刷新token接口一直失败,不是报401就是报UserDetailsService is required

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.

总结有两点原因

一:(401是因为)参数传递时,需要传递client 和 secret,不过要以Authorization方式传递
Handling error: IllegalStateException, UserDetailsService is required._第1张图片
body里面的参数
Handling error: IllegalStateException, UserDetailsService is required._第2张图片
二:(UserDetailsService is required)是因为需要在AuthorizationServerEndpointsConfigurer中引入自己实现的userDeatils接口的实现类

  @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        // 用于支持密码模式
        endpoints.authenticationManager(authenticationManager)
                // 增加 TokenStore 配置
                .tokenStore(tokenStore())
                //设置userDetailsService刷新token时候会用到
                .userDetailsService(userDetailsServiceImpl);
    }

你可能感兴趣的:(Handling error: IllegalStateException, UserDetailsService is required.)