# Renewing access token to get latest user\_metadata

**URL:** <https://community.auth0.com/t/renewing-access-token-to-get-latest-user-metadata/88792>\
**Category:** Get Help\
**Created:** [August 15, 2022, 7:26pm UTC](https://community.auth0.com/t/renewing-access-token-to-get-latest-user-metadata/88792 "2022-08-15T19:26:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanivs](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yanivs/32/38421_2.png) [@yanivs](https://community.auth0.com/u/yanivs)\
**Post date:** [August 15, 2022, 7:26pm UTC](https://community.auth0.com/t/renewing-access-token-to-get-latest-user-metadata/88792/1 "2022-08-15T19:26:51Z")

</div>

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 🙂

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 24, 2022, 8:49pm UTC](https://community.auth0.com/t/renewing-access-token-to-get-latest-user-metadata/88792/3 "2022-08-24T20:49:20Z")

</div>

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:

> [@How to refresh an access token in a Next.js application?](https://community.auth0.com/t/how-to-refresh-an-access-token-in-a-next-js-application/75806):
>
> Found [this](https://community.auth0.com/t/update-spa-token-after-user-updates-profile-through-managementapi-without-new-login/74166) question which asks about exactly the same problem: user logs in (frontend application gets an access\_token); user updates its profile, frontend sends information to the backend, backend calls the Management API user’s access\_token is now out of date on the frontend; we want it to be up to date; read [this](https://auth0.com/blog/ultimate-guide-nextjs-authentication-auth0/) tutorial - mentions that refresh\_token exists but doesn’t show how to implement them. read [this](https://auth0.com/docs/security/tokens/refresh-tokens) tutorial - it says that SPA applications should use the \*\* Authorization Code…

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

> <https://github.com/auth0/nextjs-auth0/issues/4>
>
> First of all, thanks for this great library, the struggle was so real before I c…ame across your nextjs example!
> 
> As requested in https://github.com/sandrinodimattia/nextjs-auth0-example/issues/2 :
> 
> A good feature for the next release would be to store refresh token, in order to allow getting new access tokens when needed.

---

<div class="post-metadata">

**Author:** ![yanivs](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yanivs/32/38421_2.png) [@yanivs](https://community.auth0.com/u/yanivs)\
**Post date:** [August 25, 2022, 1:16pm UTC](https://community.auth0.com/t/renewing-access-token-to-get-latest-user-metadata/88792/4 "2022-08-25T13:16:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 26, 2022, 12:19am UTC](https://community.auth0.com/t/renewing-access-token-to-get-latest-user-metadata/88792/5 "2022-08-26T00:19:25Z")

</div>

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](https://auth0.github.io/nextjs-auth0/modules/session_get_access_token.html)?
- What version of the SDK are you using?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 30, 2022, 11:05pm UTC](https://community.auth0.com/t/renewing-access-token-to-get-latest-user-metadata/88792/6 "2022-09-30T23:05:40Z")

</div>


