# Custom accessToken claim not being returned to app

**URL:** <https://community.auth0.com/t/custom-accesstoken-claim-not-being-returned-to-app/11843>\
**Category:** Get Help\
**Created:** [May 25, 2018, 5:01pm UTC](https://community.auth0.com/t/custom-accesstoken-claim-not-being-returned-to-app/11843 "2018-05-25T17:01:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam.barclay](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adam.barclay/32/8134_2.png) [@adam.barclay](https://community.auth0.com/u/adam.barclay)\
**Post date:** [May 25, 2018, 5:01pm UTC](https://community.auth0.com/t/custom-accesstoken-claim-not-being-returned-to-app/11843/1 "2018-05-25T17:01:22Z")

</div>

Hey!

I’m trying to pass a custom claim back to my app through a rule but struggling to actually get it to be passed back to the app in the accessToken JWT.

The rule implements a redirect flow, which allows the user to select which tenant to sign in. When the app ‘continues’ it passes a new value back in the JWT, decodes that and adds it to the context.accessToken:

`context.accessToken['https://app.timestamp.io/user_id'] = decoded.user_id;`

I have added logs and know that this is being set correctly. context.accessToken looks like: { “[https://app.timestamp.io/user\_id":"131072](https://app.timestamp.io/user_id%22:%22131072)”}

GIven this, the JWT generated by Auth0 DOES NOT contain this extra claim. I just get something like:

```
{
  "iss": "https://.../",
  "sub": "...",
  "aud": [
    "https://api.timestamp.io",
    "https://.../userinfo"
  ],
  "iat": 1527265982,
  "exp": 1527273182,
  "azp": "...",
  "scope": "openid timestamp:all"
}

```

I’m really not sure what else to try. I cannot see anything obvious as to why this would not work.

Appreciate any help!

Thanks, Adam

---

<div class="post-metadata">

**Author:** ![sgmeyer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sgmeyer/32/3387_2.png) [@sgmeyer](https://community.auth0.com/u/sgmeyer)\
**Post date:** [May 25, 2018, 5:04pm UTC](https://community.auth0.com/t/custom-accesstoken-claim-not-being-returned-to-app/11843/2 "2018-05-25T17:04:13Z")

</div>

@adam.barclay given what you’ve showed here it should work. Can you send me the rule you have written that augments the access token? Also, are you saying there is a redirect rule in place? If so does the accessToken get set before or after the redirect takes place?

---

<div class="post-metadata">

**Author:** ![adam.barclay](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adam.barclay/32/8134_2.png) [@adam.barclay](https://community.auth0.com/u/adam.barclay)\
**Post date:** [June 1, 2018, 2:15pm UTC](https://community.auth0.com/t/custom-accesstoken-claim-not-being-returned-to-app/11843/3 "2018-06-01T14:15:43Z")

</div>

@sgmeyer sorry I did not see this reply. I have managed to figure out what is going on. The flow was taken from the redirect example and modified.

My problem was not returning from the verifyToken call, which meant the callback function was being called _before_ the claims had been added. The confusing part was the logs outputting that the context was being correctly modified.

To help others in the future would it be possible to log an error if callback is called twice as it seems there is no situation where that would be desired?

Thank you, Adam

---

<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:** [December 17, 2018, 10:38am UTC](https://community.auth0.com/t/custom-accesstoken-claim-not-being-returned-to-app/11843/4 "2018-12-17T10:38:52Z")

</div>


