简体   繁体   中英

How do I get email from JWT using Auth 0

I am trying to follow the instructions provided here . This returns a JWT token, however, I can't figure out how to get the actual email property. I think I need to add a scope or something but I don't know JWT very well.

All I see is

iss
sub
aud
iat
exp

Can someone help?

Is this a one off or in a script? If it's just a one off you can paste it into https://jwt.io/ and it will decode the payload for you. I believe the JWT payload is just Base64 encoded clear text, so you could probably use a function to decode it too if you just need something quick and dirty.

The answer was to include the scope like this .withScope("openid profile") as in...

@Autowired
private AuthenticationController controller;
....
String authorizeUrl = controller.buildAuthorizeUrl(req, redirectUri)
                .withScope("openid profile")
                .withAudience(String.format("<>://%s/userinfo", appConfig.getDomain()))
                .build();

Now I am getting the proper info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM