Renewing access token to get latest user_metadata

Hey,

I have a NextJS app with 2 types of users: regular users and super admins. Super admins can see a read-only version of the app as one of the regular users. I’m achieving this by having an “override” prop in the user_metadata of super admins that contains the id of a regular user we want to view the app as.
When I login to the system I have an action that puts the user metadata in the access token.

The problem is that I want to be able to change the “override” prop on the app and send the latest user_metadata in the access token. is it possible to “renew” the access token to get the latest user metadata? or maybe you have another idea to do what I’m trying to do :slight_smile:

Thanks a lot!

Hi @yanivs,

Welcome to the Auth0 Community!

You can use a refresh token to get a new token access token.

Here is a topic that explains it:

and here is a GH issue that contains more info and an example from the SDK:

1 Like

Hey @dan.woda , first of all thanks a lot!

I’m not quite sure I understand how to implement it with 1.0.0 version, because there we don’t use the auth0 instance, but the handleAuth function that covers all of auth0 endpoints.
If I want to use refresh tokens I can’t do it with the handleAuth function?

Hm, I may need to reach out to the team to figure this out.

Can you give us some more information about what you are doing?

  • Are you doing this in the frontend or backend of your next app?
  • Can you please provide a code snippet of how you are retrieving the user metadata?
  • Have you looked at using the getAccessToken method?
  • What version of the SDK are you using?