# Difficulties in Adding Non-Restricted Claims to JWT Token

**URL:** <https://community.auth0.com/t/difficulties-in-adding-non-restricted-claims-to-jwt-token/105706>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [April 28, 2023, 6:54am UTC](https://community.auth0.com/t/difficulties-in-adding-non-restricted-claims-to-jwt-token/105706 "2023-04-28T06:54:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayden](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ayden/32/34598_2.png) [@ayden](https://community.auth0.com/u/ayden)\
**Post date:** [April 28, 2023, 6:54am UTC](https://community.auth0.com/t/difficulties-in-adding-non-restricted-claims-to-jwt-token/105706/1 "2023-04-28T06:54:20Z")

</div>

Hello everyone,

I’m having difficulty adding the `email_verified` to the JWT token through the use of the [Authorization Code Flow](https://auth0.com/docs/api/authentication#get-token) from the [Authentication API](https://auth0.com/docs/api/authentication).

I’ve tried to add the `email_verified` to the token using the Flow but have been unsuccessful thus far.

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (event.authorization) {
    api.idToken.setCustomClaim(`email_verified`, event.user.email_verified);
  }
};

```

I am having trouble with the code above since it’s not working as intended. However, I found that renaming the property `email_verified` to `email_verified_abc` made it function properly and display on the JWT Token.

Can you please guide me on how to display the `email_verified` property on the JWT Token?

---

<div class="post-metadata">

**Author:** ![peter.fernandez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/peter.fernandez/32/45477_2.png) [@peter.fernandez](https://community.auth0.com/u/peter.fernandez)\
**Post date:** [April 28, 2023, 9:41am UTC](https://community.auth0.com/t/difficulties-in-adding-non-restricted-claims-to-jwt-token/105706/2 "2023-04-28T09:41:58Z")

</div>

Hi @ayden 👋

There are a number of restrictions related to using non-namespaced custom claims in Auth0. This is to avoid accidental override of security/PII sensitive information, or situations where there could be a conflict with values set as part of the standard(s). You can read more information [here](https://auth0.com/docs/secure/tokens/json-web-tokens/create-custom-claims).

Claims can also unintentionally provide bad actors with valuable information regarding PII, so often reading these via a non-browser based flows - such as via a direct call to the Auth0 `/userinfo` endpoint can be a more suitable solution. Particularly where such information is required by an API, say.

If you do have a specific need to set additional claims in either an _ID Token_ or an _Access Token_ then doing so via use of a namespacing is often the best way to go. FYI, `email_verified` is already a default claim set by Auth0 as part of a returned _ID Token_.

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![ayden](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ayden/32/34598_2.png) [@ayden](https://community.auth0.com/u/ayden)\
**Post date:** [April 28, 2023, 9:53am UTC](https://community.auth0.com/t/difficulties-in-adding-non-restricted-claims-to-jwt-token/105706/3 "2023-04-28T09:53:48Z")

</div>

Hello Peter,

Are you saying the ID Token can be obtained from `/oauth/token`?  
If so, after obtaining and decoding the JWT token, I did not find the presence of the `email_verified` property.

---

<div class="post-metadata">

**Author:** ![peter.fernandez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/peter.fernandez/32/45477_2.png) [@peter.fernandez](https://community.auth0.com/u/peter.fernandez)\
**Post date:** [April 28, 2023, 10:09am UTC](https://community.auth0.com/t/difficulties-in-adding-non-restricted-claims-to-jwt-token/105706/4 "2023-04-28T10:09:43Z")

</div>

> [@ayden](#):
>
> Are you saying the ID Token can be obtained from `/oauth/token`?  
> If so, after obtaining and decoding the JWT token, I did not find the presence of the `email_verified` property.

So the ID Token can be obtained in a variety of ways: if you’re using [_Authorization Code_](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow) flow - the recommended option - with, or without, PKCE it is typically obtained from the Auth0 `oath/token` endpoint; if you’re using [_Implicit_](https://auth0.com/docs/authenticate/login/oidc-conformant-authentication/oidc-adoption-implicit-flow) flow then it is typically returned via the browser.

To get the `email_verified` claim by default, the calling `scope` (see [here](https://auth0.com/docs/get-started/apis/scopes/openid-connect-scopes) for more details) should include `email`. This will also return the email address for the user, so if all you are wanting is `email_verified` then you will need to set this as a namespaced custom claim.

Hope this helps 🕶

---

<div class="post-metadata">

**Author:** ![ayden](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ayden/32/34598_2.png) [@ayden](https://community.auth0.com/u/ayden)\
**Post date:** [April 28, 2023, 12:37pm UTC](https://community.auth0.com/t/difficulties-in-adding-non-restricted-claims-to-jwt-token/105706/5 "2023-04-28T12:37:33Z")

</div>

I appreciate the help, Peter.

I will look into it. Thank you.

---

<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:** [April 28, 2023, 1:33pm UTC](https://community.auth0.com/t/difficulties-in-adding-non-restricted-claims-to-jwt-token/105706/6 "2023-04-28T13:33:29Z")

</div>

Let us know if you have any other questions related to that!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 12, 2023, 1:33pm UTC](https://community.auth0.com/t/difficulties-in-adding-non-restricted-claims-to-jwt-token/105706/7 "2023-05-12T13:33:44Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
