# Session Expiry Issues After Upgrading to nextjs-auth0 v4

**URL:** <https://community.auth0.com/t/session-expiry-issues-after-upgrading-to-nextjs-auth0-v4/192984>\
**Category:** Get Help\
**Tags:** sessions, access-token\
**Created:** [October 9, 2025, 7:50am UTC](https://community.auth0.com/t/session-expiry-issues-after-upgrading-to-nextjs-auth0-v4/192984 "2025-10-09T07:50:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![apps.oh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/apps.oh/32/76962_2.png) [@apps.oh](https://community.auth0.com/u/apps.oh)\
**Post date:** [October 9, 2025, 7:50am UTC](https://community.auth0.com/t/session-expiry-issues-after-upgrading-to-nextjs-auth0-v4/192984/1 "2025-10-09T07:50:15Z")

</div>

We are currently upgrading our project from **nextjs-auth0 v3** to **v4** and have encountered some issues in our production environment.

In our **development** and **staging** environments (both connected to the Auth0 sandbox), the upgrade has been successfully verified, and all login flows are functioning correctly. However, when deploying to **production** , we are facing the following problems:

1. **Session expires 5 minutes after login for all accounts**

2. **Google login not working for specific accounts**

**Confirmed details:**

- The exact same code works correctly in both **staging** and **development** :

- We’ve reviewed the configuration differences between Auth0 **prod** and **sandbox** , and found no critical discrepancies.

- When the session expires in the production environment, there are **no corresponding error logs** on the Auth0 production tenant.

- The **x-vercel-id** for both staging and production deployments is identical.

- The

We would greatly appreciate your assistance in identifying the cause of these issues and guidance on how to resolve them.

Best regards,

---

<div class="post-metadata">

**Author:** ![remus.ivan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/remus.ivan/32/68771_2.png) [@remus.ivan](https://community.auth0.com/u/remus.ivan)\
**Post date:** [October 13, 2025, 6:24pm UTC](https://community.auth0.com/t/session-expiry-issues-after-upgrading-to-nextjs-auth0-v4/192984/3 "2025-10-13T18:24:19Z")

</div>

Hi @apps.oh,

Welcome to the Auth0 Community!

I have checked the tenant logs associated with your community account and it seems that you are experiencing lots of [fertft log type codes](https://auth0.com/docs/deploy-monitor/logs/log-event-type-codes). This KB Article - [Refresh Token Exchange - fertft Events “Token could not be decoded or is missing in DB”](https://support.auth0.com/center/s/article/refresh-token-exchange-fertft-events-token-could-not-be-decoded-or-is-missing-in-db) explains the cause of this error code occurring.

What i would suggest is to make sure that your application follows this rules for implementing the correct configuration for enabling Refresh Tokens in your application:

1. Include the ‘offline\_access’ scope in your authentication request.

2. Enable “ **Allow Offline Access** ” in your **API settings**.

```javascript
const accessToken = await getAccessToken(req, res, {refresh: true};

```

This article should be relevant to your case - [NextJS GetAccessToken() Always Returns Error “The access token expired and a refresh token is not available”](https://community.auth0.com/t/nextjs-getaccesstoken-always-returns-error-the-access-token-expired-and-a-refresh-token-is-not-available/137671).

About your 2nd inquiry regarding specific users not being able to login using the google social connection, there could be multiple reasons as of why this could be happening. Firstly I would suggest checking your application logs when users are unable to authenticate successfully. Causes could differ from specific user issues, such as not providing full access in the consent screen, settings within their account or general google policies restricting access to 3rd party apps to confirming that the consent page has been published for External users, listing your application as **in Production** on the Google Console Platform or setting up Production keys for the Google Social connection. Leaving this documentation here in case it might help:

- [Can not login with Google Social on a custom domain](https://support.auth0.com/center/s/article/Can-not-login-with-Google-on-a-custom-domain)

- [Error “There was an error. Please try again later. That’s all we know” Seen when Using the Google-Oauth2 Connection with Google Production Keys](https://support.auth0.com/center/s/article/Google-Social-Connection-does-not-allow)

I hope this helps, and if you have further inquires into these matters some additional context would be greatly appreciated.

Thank you,

Remus

---

<div class="post-metadata">

**Author:** ![apps.oh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/apps.oh/32/76962_2.png) [@apps.oh](https://community.auth0.com/u/apps.oh)\
**Post date:** [October 15, 2025, 1:00am UTC](https://community.auth0.com/t/session-expiry-issues-after-upgrading-to-nextjs-auth0-v4/192984/4 "2025-10-15T01:00:30Z")

</div>

Hi Remus,

Thank you very much for your detailed reply.

We have confirmed that the following settings are already enabled in our environment:

- The `offline_access` scope is included in the authentication request.

- “Allow Offline Access” is enabled in the API settings.

- The “Refresh Token” grant type is enabled in the application settings.

Currently, our implementation calls `getAccessToken()` **without specifying any options**.  
According to the **nextjs-auth0 v4** documentation, the SDK is supposed to automatically handle access token renewal internally — and indeed, this works correctly in both our **dev** and **staging** environments (connected to the Auth0 sandbox).

However, only in our **production** environment (connected to the Auth0 production tenant), the access token expires after 5 minutes and does not seem to refresh automatically.

Do we need to explicitly call `getAccessToken({ refresh: true })` in production, even though the v4 SDK is expected to manage token renewal automatically?  
Or could this behavior indicate a configuration or tenant-level difference between our sandbox and production Auth0 environments?

Thank you again for your support and guidance.

Best regards

---

<div class="post-metadata">

**Author:** ![remus.ivan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/remus.ivan/32/68771_2.png) [@remus.ivan](https://community.auth0.com/u/remus.ivan)\
**Post date:** [October 15, 2025, 6:37pm UTC](https://community.auth0.com/t/session-expiry-issues-after-upgrading-to-nextjs-auth0-v4/192984/5 "2025-10-15T18:37:15Z")

</div>

Hi @apps.oh,

This should generally work regardless of the environment used, and would typically mean an issue within the configuration.

Just to make sure that we are on the same page, even though I have previously mentioned that the offline\_access scope should be initialized in the authentication request, this should actually be specified when initiating the Auth0Client such as:

```auto
export const auth0 = new Auth0Client({ 
    authorizationParameters: {   
      scope: "openid profile email offline_access", 
      audience: "urn:custom:api", 
}, 

})

```

Other than that using the `getAccessToken({ refresh: true })` option should fix the issue recognized from the error logs for the refresh token being either expired, reused or revoked by making sure it will renew the token whenever it’s necessary.

Best regards,  
Remus

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 29, 2025, 6:37pm UTC](https://community.auth0.com/t/session-expiry-issues-after-upgrading-to-nextjs-auth0-v4/192984/6 "2025-10-29T18:37:39Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
