How to get Claims - email from JWT

I was using the Spring 5 - auth0 example
and want email claim, but I don’t get it why? Calling endpoint from postman, and specifying scope = openid profile email.

@GetMapping(value = "/private")
public Message privateEndpoint(@AuthenticationPrincipal Jwt jwt) {
	Map<String, Object> claims = jwt.getClaims();
    for (Object key: claims.keySet()) {
        System.out.println("key: and value: "+ key.toString());// + "..."+  claims.get(key).asString());
    } 

key: and value: sub
key: and value: aud
key: and value: azp
key: and value: scope
key: and value: iss
key: and value: exp
key: and value: iat

what am I missing please?

I didn’t find any example in Auth0. will try Okta or other. Sad that I had wasted a lot of time

Hi @k-auth0

You don’t say whether you are looking at the access token or the ID token. I think it is the access token you are looking at. You should try the ID token instead. Or you can add the email to the access token with a rule.

John

I am thinking similarly, but how to get it please? what are the steps?

I see …a rule…what is namespace?

function addEmailToAccessToken(user, context, callback) {
// This rule adds the authenticated user’s email address to the access token.

var namespace = ‘https://example.com/’;

context.accessToken[namespace + ‘email’] = user.email;
return callback(null, user, context);
}

Is this rocket science to answer??