can I include user information while issuing an access token?

后端 未结 6 670
無奈伤痛
無奈伤痛 2020-11-28 03:58

I have seen in some oauth2 implementations additional information on the response returned by the authorization server when it issues access tokens. I\'m wondering if there

6条回答
  •  误落风尘
    2020-11-28 04:24

    Together with:

    @Bean
    public TokenEnhancer tokenEnhancer() {
       return new CustomTokenEnhancer();
    }
    

    You have to include

    @Bean
    public DefaultAccessTokenConverter accessTokenConverter() {
        return new DefaultAccessTokenConverter();
    }
    

    and add everything to endpoints config:

    @Override
        public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
    
            endpoints
                    .tokenStore(tokenStore)
                    .tokenEnhancer(tokenEnhancer())
                    .accessTokenConverter(accessTokenConverter())
                    .authorizationCodeServices(codeServices)
                    .authenticationManager(authenticationManager)
            ;
        }
    

    Without it, your CustomTokenEnhancer will not work.

提交回复
热议问题