# Check custom claim in access\_token

**URL:** <https://community.auth0.com/t/check-custom-claim-in-access-token/99054>\
**Category:** Get Help\
**Tags:** oidc-enterprise-connection, connections\
**Created:** [January 26, 2023, 7:14pm UTC](https://community.auth0.com/t/check-custom-claim-in-access-token/99054 "2023-01-26T19:14:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![accounts.seclookup](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/accounts.seclookup/32/44003_2.png) [@accounts.seclookup](https://community.auth0.com/u/accounts.seclookup)\
**Post date:** [January 26, 2023, 7:14pm UTC](https://community.auth0.com/t/check-custom-claim-in-access-token/99054/1 "2023-01-26T19:14:42Z")

</div>

I have integrated auth0 OIDC service with 3 applications.  
It was required that I use nickname as the `preffered_username` in those applications.

As per requirements I have added the custom claim, but I see errors in my application stating that claim `nickname` not found. Since I cannot use postman to fetch `access_token`, what should be my proper flow to check the access token claims.

If auth0 claim is perfect, then it might be my application that is fault, but I am unable to confirm whether auth0 is sending the claim in JWT.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 26, 2023, 10:35pm UTC](https://community.auth0.com/t/check-custom-claim-in-access-token/99054/3 "2023-01-26T22:35:00Z")

</div>

Hi there @accounts.seclookup welcome to the community!

> [@accounts.seclookup](#):
>
> If auth0 claim is perfect, then it might be my application that is fault, but I am unable to confirm whether auth0 is sending the claim in JWT.

Are you able to get a hold of an example access token in one of your applications? You can decode it at [jwt.io](http://jwt.io).

How are you adding the custom claim? If you’d like to share any extensibility code (Action, Rule, etc.) here I’d be happy to take a look.

Auth0 provides sample apps for all supported technologies so it may be worth configuring one to test with if you are unable to in your own applications.

> **[Auth0 Samples](https://github.com/auth0-samples)**
>
> Auth0 Samples has 121 repositories available. Follow their code on GitHub.

Keep us posted!

---

<div class="post-metadata">

**Author:** ![accounts.seclookup](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/accounts.seclookup/32/44003_2.png) [@accounts.seclookup](https://community.auth0.com/u/accounts.seclookup)\
**Post date:** [January 27, 2023, 4:15am UTC](https://community.auth0.com/t/check-custom-claim-in-access-token/99054/4 "2023-01-27T04:15:28Z")

</div>

Hello @ty.frith Thank you for your reply.

> Are you able to get a hold of an example access token in one of your applications? You can decode it at [jwt.io](http://jwt.io/).

I am not able to get hold of the token in my application due to some reasons.

I have added Rules to add the custom claim to my token.  
So, is there a way I can see what token auth0 sends to the application?

---

<div class="post-metadata">

**Author:** ![accounts.seclookup](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/accounts.seclookup/32/44003_2.png) [@accounts.seclookup](https://community.auth0.com/u/accounts.seclookup)\
**Post date:** [January 27, 2023, 4:17am UTC](https://community.auth0.com/t/check-custom-claim-in-access-token/99054/5 "2023-01-27T04:17:22Z")

</div>

This is the rule if it helps

```auto
function addNicknameToAccessToken(user, context, callback) {
  // This rule adds the authenticated user's nickname to the access token.

  var namespace = 'https://seclookup.com/';

  context.accessToken[namespace + 'nickname'] = user.nickname;
  return callback(null, user, context);
}

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 30, 2023, 8:03pm UTC](https://community.auth0.com/t/check-custom-claim-in-access-token/99054/6 "2023-01-30T20:03:20Z")

</div>

Thanks for getting back to me, and the rule code definitely helps!

I can confirm that the rule works as expected - I just tested this in my own environment.

> [@accounts.seclookup](#):
>
> I have added Rules to add the custom claim to my token.  
> So, is there a way I can see what token auth0 sends to the application?

You should be able to use the [Resource Owner Password Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/resource-owner-password-flow) to get an access token as long as that grant is enabled for your application. For example, I used a SPA app with the password grant type enabled (Application → Advanced Settings → Grant Types) and a curl request like the following:

```auto
curl --location --request POST 'https://{my_domain}.us.auth0.com/oauth/token' \
--header 'Content-Type: application/json' \
--data-raw '{
  "client_id": "5sFZ3AXXX",
  "username": "username@gmail.com",
   "password":"password",
   "audience": "https://my-test-api-endpoint",
   "scope": "openid profile email",
  "grant_type":"password"
}'

```

This should return an access token you can inspect at [jwt.io](http://jwt.io) - Like I said, your rule works as expected. Assuming you’ve switched that on in your tenant settings then my guess is this is breaking down elsewhere.

Keep us posted!

---

<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:** [February 13, 2023, 8:03pm UTC](https://community.auth0.com/t/check-custom-claim-in-access-token/99054/7 "2023-02-13T20:03:24Z")

</div>

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