How to use the refresh token with @auth0/nextjs-auth0

Hi there,

basically my question is, how to use the refresh_token with the @auth0/nextjs-auth0 sdk?

Do i need to implement a whole new request like in this documentation:

Use Refresh Tokens ? Or is there a function withing the sdk?

Hey @me1k !

You can get/use refresh tokens using the SDK directly (plus a couple tenant settings) - Please see here:

Hmm and what bulletpoint do you refer to exactly? I guess Create your own instance of the SDK ?

1 Like

The link should point to getting a refresh token.

But then i dont understand it. I already get a refresh token. But i wondered, if there is a built in way of the SDK to use the refresh token, to get a new access token/token id

1 Like

Ahh gotcha - Assuming you’ve configured your application and dashboard correctly (outlined in the steps linked) the SDK should handle refreshing the token for you.

But i somehow need to know this in the Frontend, right? So i after my first login i request an accessToken/idToken and after 5mins i want fetch a new token with my refreshToken … and i wonder, if there is a built in way from the SDK or if i need to handle this on my own.

Because here it says, i need to do a extra request on my own to get a new token:
https://auth0.com/docs/secure/tokens/refresh-tokens/use-refresh-tokens

1 Like

Hey @me1k sorry for the delayed response here - According to the docs here specifically for withApiAuthRequired calling getAccessToken will result in a refreshed access token if it’s expired and assuming you have a valid refresh token.

does the getSession function refresh the access token or is it only the getAccessToken that does that?

1 Like

Only getAccessToken will renew tokens with a valid refresh token.