Search code examples
springspring-bootspring-security-oauth2

Not able to generate JWT token by Spring Boot OAuth2


I am a bit new to generate OAuth JWT tokens. I have been trying to implement an Authorization Server by using Spring Boot OAuth. The problem I am facing is I am not able to generate the JWT token, rather it generates a simple token and not JWT one.

enter image description here

I have created the project in GitHub . Please see the link https://github.com/jainaks2010/OAuth2AuthorizationServer

I am using POSTMan to generate - enter image description here

enter image description here


Solution

  • I think you need to add the converter to the endpoints like so:

        @Override
        public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
            endpoints
                .tokenStore(tokenStore())
                .accessTokenConverter(jwtAccesTokenConvertor()) // <-- This one
                .authenticationManager(authenticationManager)
                .userDetailsService(userDetailsService);
        }