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
andcacheMode: "off"
in thegetAccessTokenSilently
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!