Managing Google Refresh tokens in Auth0 and Next JS

Hi all!

I am trying to figure out how to set up my Auth0 app to handle Google access tokens correctly. I am building an app that allows users to log in and then (in response to webhook triggers) we check their calendar and other resources. The app is a Next JS app using auth0/nextjs-auth0. I understand how to get a Google access token using the management API, however, I am finding that the Google token doesn’t work after a day or so. My understanding is that I need to configure google for offline access and get a refresh token, however I’m not finding any details on how to establish offline access to Google through Auth0 in the Next JS library.
Below is my AUTH0_SCOPES environment variable:
AUTH0_SCOPES='openid profile email offline_access'

I’m handling user authentication using the /api/auth/[…auth0].ts route.

Based on my understanding of the Management API, Auth0 should be re-authenticating my Google connection after I make a request to /api/v2/users, and each request does succeed and return the full user profile, but it does not seem to be refreshing the Google connection.

1 Like


I encountered an issue with the “access_token” being expired while using /api/v2/users. I called the management API “/oauth/token” and used the token received to get the User, but the “access_token” remained the same as the first one received.

I’m stuck on how to get a new access_token or updated access_token. Do you have any ideas?