# Refreshed token doesn't include the custom claim added during login

**URL:** <https://community.auth0.com/t/refreshed-token-doesnt-include-the-custom-claim-added-during-login/138971>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [July 15, 2024, 9:52pm UTC](https://community.auth0.com/t/refreshed-token-doesnt-include-the-custom-claim-added-during-login/138971 "2024-07-15T21:52:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ameen](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ameen/32/58632_2.png) [@ameen](https://community.auth0.com/u/ameen)\
**Post date:** [July 15, 2024, 9:52pm UTC](https://community.auth0.com/t/refreshed-token-doesnt-include-the-custom-claim-added-during-login/138971/1 "2024-07-15T21:52:40Z")

</div>

Hello guys,

I have a custom action that I added to the “Login” flow to add custom claims, in this case the email of the user:

exports.onExecutePostLogin = async (event, api) =\> {  
if (event.authorization) {  
api.accessToken.setCustomClaim(“email”, event.user.email);  
}  
};

On my Android app, I’m using the refresh token to get a new access token, it works however the new access token doesn’t have the custom claim, how can I allow new access tokens have the same claims (using the refresh token)?

Here’s my Android code that does the refresh (for reference):

val client = AuthenticationAPIClient(auth0)  
var newAccessToken = “”  
try {  
client.renewAuth(refreshToken)  
.start(object: Callback\<Credentials, AuthenticationException\> {  
override fun onFailure(error: AuthenticationException) {  
Log.e(“AUTH0 Error”, “onFailure: $error”)  
}

```
        override fun onSuccess(result: Credentials) {
          newAccessToken = result.accessToken
          Log.e("AUTH0 Success", "onSuccess: $result")
        }
      })

```

---

<div class="post-metadata">

**Author:** ![taylor.briggs](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/taylor.briggs/32/46588_2.png) [@taylor.briggs](https://community.auth0.com/u/taylor.briggs)\
**Post date:** [July 17, 2024, 6:11pm UTC](https://community.auth0.com/t/refreshed-token-doesnt-include-the-custom-claim-added-during-login/138971/4 "2024-07-17T18:11:28Z")

</div>

> [@ameen](#):
>
> if (event.authorization) {  
> api.accessToken.setCustomClaim(“email”, event.user.email);  
> }

Why do you wrap it in the conditional? That event property is likely not included when using the refresh token, which is why the claim is missing from the refreshed access token. If you always want the email claim included in your access token, remove the condition.

---

<div class="post-metadata">

**Author:** ![ameen](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ameen/32/58632_2.png) [@ameen](https://community.auth0.com/u/ameen)\
**Post date:** [July 17, 2024, 6:49pm UTC](https://community.auth0.com/t/refreshed-token-doesnt-include-the-custom-claim-added-during-login/138971/5 "2024-07-17T18:49:06Z")

</div>

Thanks @taylor.briggs, let me check and confirm.

---

<div class="post-metadata">

**Author:** ![thushalya](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thushalya/32/62532_2.png) [@thushalya](https://community.auth0.com/u/thushalya)\
**Post date:** [November 26, 2024, 3:17pm UTC](https://community.auth0.com/t/refreshed-token-doesnt-include-the-custom-claim-added-during-login/138971/6 "2024-11-26T15:17:59Z")

</div>

Hello ameen, @ameen

is it worked?

---

<div class="post-metadata">

**Author:** ![ameen](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ameen/32/58632_2.png) [@ameen](https://community.auth0.com/u/ameen)\
**Post date:** [November 27, 2024, 8:52am UTC](https://community.auth0.com/t/refreshed-token-doesnt-include-the-custom-claim-added-during-login/138971/7 "2024-11-27T08:52:10Z")

</div>

It did! Thanks guys.

---

<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:** [December 11, 2024, 8:52am UTC](https://community.auth0.com/t/refreshed-token-doesnt-include-the-custom-claim-added-during-login/138971/8 "2024-12-11T08:52:31Z")

</div>

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