# How to get Claims - email from JWT

**URL:** <https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213>\
**Category:** Get Help\
**Tags:** jwt, api, auth0\
**Created:** [December 21, 2020, 11:36pm UTC](https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213 "2020-12-21T23:36:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![k-auth0](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/k-auth0/32/18365_2.png) [@k-auth0](https://community.auth0.com/u/k-auth0)\
**Post date:** [December 21, 2020, 11:36pm UTC](https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213/1 "2020-12-21T23:36:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![k-auth0](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/k-auth0/32/18365_2.png) [@k-auth0](https://community.auth0.com/u/k-auth0)\
**Post date:** [December 22, 2020, 11:55am UTC](https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213/2 "2020-12-22T11:55:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [December 22, 2020, 3:07pm UTC](https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213/3 "2020-12-22T15:07:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![k-auth0](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/k-auth0/32/18365_2.png) [@k-auth0](https://community.auth0.com/u/k-auth0)\
**Post date:** [December 22, 2020, 4:36pm UTC](https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213/4 "2020-12-22T16:36:52Z")

</div>

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/](https://example.com/)’;

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

---

<div class="post-metadata">

**Author:** ![k-auth0](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/k-auth0/32/18365_2.png) [@k-auth0](https://community.auth0.com/u/k-auth0)\
**Post date:** [February 19, 2021, 5:33pm UTC](https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213/5 "2021-02-19T17:33:05Z")

</div>

Is this rocket science to answer??

---

<div class="post-metadata">

**Author:** ![Gunjan.Parmar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gunjan.parmar/32/35013_2.png) [@Gunjan.Parmar](https://community.auth0.com/u/Gunjan.Parmar)\
**Post date:** [March 24, 2022, 8:46pm UTC](https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213/6 "2022-03-24T20:46:35Z")

</div>

see if this helps, [Include email in JWT - #3 by johnykes](https://community.auth0.com/t/include-email-in-jwt/39778/3)

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 25, 2022, 7:18am UTC](https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213/7 "2022-03-25T07:18:58Z")

</div>

Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 31, 2022, 10:59am UTC](https://community.auth0.com/t/how-to-get-claims-email-from-jwt/55213/8 "2022-03-31T10:59:52Z")

</div>


