Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.0.0-beta.12: Unknown or invalid refresh token thrown from middleware #1851

Closed
6 tasks done
chris-erickson opened this issue Dec 19, 2024 · 2 comments
Closed
6 tasks done

Comments

@chris-erickson
Copy link

Checklist

Description

I followed the middleware setup instructions. If I leave a web app running overnight with inactivity, routes start triggering this error in the middleware.

Reproduction

ResponseBodyError: server responded with an error in the response body
    at async middleware (middleware.ts:8:18)
   6 |
   7 | export async function middleware(request: NextRequest) {
>  8 |   const authRes = await auth0.middleware(request);
     |                  ^
   9 |
  10 |   // authentication routes — let the middleware handle it
  11 |   if (request.nextUrl.pathname.startsWith("/auth")) { {
  code: 'OAUTH_RESPONSE_BODY_ERROR',
  error: 'invalid_grant',
  status: 403,
  error_description: 'Unknown or invalid refresh token.'

Additional context

No response

nextjs-auth0 version

v4.0.0-beta.12

Next.js version

15.1.1

Node.js version

v20.17.0

@guabu guabu mentioned this issue Dec 19, 2024
@guabu
Copy link

guabu commented Dec 19, 2024

Hey @chris-erickson 👋 Thanks for the feedback! We're addressing this as part of another set of fixes around fetching and refreshing access tokens (linked above).

We'll be moving away from automatically refreshing access tokens in the middleware so this should fix the issue you're reporting.

@guabu
Copy link

guabu commented Dec 20, 2024

This should be fixed in the latest release (4.0.0-beta.13). We've moved the access token refresh handling from the middleware to the getAccessToken handler so you should no longer be running into this issue after upgrading. Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants