user3940641
user3940641

Reputation:

How to get userinfo by jwt token in spring security oauth2 authorization server?

I implement a oauth2 authorization server by spring security oauth2 and use JwtTokenStore to store access token,then I need to provider a /userinfo controller for current access token to get user info by an oauth2 client,the /userinfo as follow:

 @RequestMapping("/userinfo")
    public Object getCurrentUserInfo(HttpServletRequest request) {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return authentication;
    }

but I don't know how to get userinfo?

Upvotes: 0

Views: 4351

Answers (1)

user3940641
user3940641

Reputation:

Maybe need read more OAuth 2 Developers Guide .Know function for Authorization Server,Resource Server and OAuth 2.0 Client,know spring security.

To get userinfo by access token ,should config a resource server in the Authorization Server too. Because resource server provider a filter OAuth2AuthenticationProcessingFilter to get user info by token and set into SecurityContextHolder.

Upvotes: 1

Related Questions