# Unable to Refresh JWT with Updated Custom Claims in React App Using Auth0 Refresh Tokens

**URL:** <https://community.auth0.com/t/unable-to-refresh-jwt-with-updated-custom-claims-in-react-app-using-auth0-refresh-tokens/142188>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [August 30, 2024, 4:49pm UTC](https://community.auth0.com/t/unable-to-refresh-jwt-with-updated-custom-claims-in-react-app-using-auth0-refresh-tokens/142188 "2024-08-30T16:49:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![david54](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@david54](https://community.auth0.com/u/david54)\
**Post date:** [August 30, 2024, 4:49pm UTC](https://community.auth0.com/t/unable-to-refresh-jwt-with-updated-custom-claims-in-react-app-using-auth0-refresh-tokens/142188/1 "2024-08-30T16:49:19Z")

</div>

Hi Auth0 Community,

I’m currently facing an issue with refreshing JWT tokens in my React JS application that uses Auth0 with refresh tokens enabled (`useRefreshTokens: true`). Here is my setup and the problem I’m encountering:

### Setup:

- I’m using Auth0 in a React JS app, and I’ve enabled the use of refresh tokens.
- I’ve added custom JWT claims via an Action in the Flow, specifically using the `onExecutePostLogin` action.
- After modifying these custom claims in the `onExecutePostLogin` action, I want to refresh the JWT token so that the updated claims are reflected in the token.

### Problem:

Even though I call `getAccessTokenSilently({ ignoreCache: true, cacheMode: "off" })`, the returned access token still contains the old claims. I can confirm that the `onExecutePostLogin` action is triggered and the claims are indeed being updated on the backend. However, the access token my application receives still has the outdated claims.

### What I’ve Tried:

- Using `ignoreCache: true` and `cacheMode: "off"` in the `getAccessTokenSilently` method to bypass any caching.
- Verifying that the `onExecutePostLogin` Action is working as expected and that the claims are updated correctly during the login process.

### Question:

How can I force the Auth0 React SDK to return an access token with the updated custom claims immediately, without requiring the user to log out and log back in or waiting until the token naturally expires?

Any guidance or advice on how to achieve this would be greatly appreciated!

**Thank you!**

---

<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:** [August 30, 2024, 8:21pm UTC](https://community.auth0.com/t/unable-to-refresh-jwt-with-updated-custom-claims-in-react-app-using-auth0-refresh-tokens/142188/3 "2024-08-30T20:21:40Z")

</div>

Hey there @david54 welcome to the community!

> [@david54](#):
>
> Even though I call `getAccessTokenSilently({ ignoreCache: true, cacheMode: "off" })`, the returned access token still contains the old claims. I can confirm that the `onExecutePostLogin` action is triggered and the claims are indeed being updated on the backend. However, the access token my application receives still has the outdated claims.

First off, you’re on the right track in terms of refreshing tokens to get new claims. What do you mean by claims are indeed being updated on the backend? Does the expiration on the refreshed access token get updated as expected? Can you share your action code as well?

---

<div class="post-metadata">

**Author:** ![david54](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@david54](https://community.auth0.com/u/david54)\
**Post date:** [August 30, 2024, 8:39pm UTC](https://community.auth0.com/t/unable-to-refresh-jwt-with-updated-custom-claims-in-react-app-using-auth0-refresh-tokens/142188/4 "2024-08-30T20:39:19Z")

</div>

Hi Tyf,

Thanks for your comment and warm welcome.

I was able to find the solution in the meantime. The issue was in the onExecutePostLogin action. When not using the refresh token, all the authorizationParams from the getAccessTokenSilently function are passed to the onExecutePostLogin in the event.request.query property. However, when using the refresh token, the parameters are passed in event.request.body. Once I updated the onExecutePostLogin action, everything started working as expected.

---

<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:** [August 30, 2024, 8:40pm UTC](https://community.auth0.com/t/unable-to-refresh-jwt-with-updated-custom-claims-in-react-app-using-auth0-refresh-tokens/142188/5 "2024-08-30T20:40:55Z")

</div>

Hey @david54 that’s great! Thanks for confirming.

---

<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:** [September 13, 2024, 8:41pm UTC](https://community.auth0.com/t/unable-to-refresh-jwt-with-updated-custom-claims-in-react-app-using-auth0-refresh-tokens/142188/6 "2024-09-13T20:41:26Z")

</div>

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