Open uutahan opened 8 months ago
This seems like something I'm having issues with. I'm getting:
[AccessTokenError]: The request to refresh the access token failed. CAUSE: invalid_grant (Unknown or invalid refresh token.)
The session is fine but it would seem the getAccessToken is using old(first) refresh token.
Even though I'm using it in the /api/endpoint/route.ts as per docs: https://auth0.github.io/nextjs-auth0/functions/edge.getAccessToken-1.html
With withApiAuthRequired which passes but then getAccessToken gets invalid token after a while. I think it's the same case as in here: https://github.com/nextauthjs/next-auth/discussions/6642#discussioncomment-5942013 even though, it's different library.
anybody found a solution for this? why does not middleware automatically logs out user when token is expired?
Checklist
Description
Let's say client navigates to new page. And in the server component for that page we try to get access token, if getAccessToken was expired in the mean time trying to get one will throw an error. Even if you wrap your middleware with authRequired getAccessToken throws because you still have a session(so you pass through authRequired) but your access token expired so it throws an error.
I couldn't find any examples what to do in this scenario going through docs. I've tried redirecting user to /api/auth/login, but that also doesn't work properly because nextjs tries to fetch it as rsc payload first and then falls back to browser navigation and finally recovers. Is there a recommended way for doing this?
Reproduction
Additional context
No response
nextjs-auth0 version
3.5.0
Next.js version
14.0.3
Node.js version
20.9.0