Replies: 6 comments 10 replies
-
I have exactly the same problem as you, which version of Next are you running ? The refresh token is not refreshed using |
Beta Was this translation helpful? Give feedback.
-
Based on my findings, If we reload the page, the access token is still valid, so refreshAccessToken is not called, and the refreshToken remains the same. But when we leave the session, the access token expires and refreshAccessToken is called, which will update the refreshToken. @balazsorban44 could you please point out if there is anything wrong in the code? Or should I have to add anything on top? And also the token expiry time in our back end is set to 5mins, should we have to reduce that even more? If this was an issue with the Next 13 then other usages of the next-auth works as intended (check other usages using source graph) |
Beta Was this translation helpful? Give feedback.
-
next-auth doc says,
@balazsorban44 @Max0u will this be fixed, if I use |
Beta Was this translation helpful? Give feedback.
-
I came across this same problem with 15s. token. Both 15 seconds and a minute are considered a very short expiration time for a token. Real projects usually use 15-minute tokens. |
Beta Was this translation helpful? Give feedback.
-
Hi! Have you solved the problem with the token update? I have the same problem, I use next.js v.14 |
Beta Was this translation helpful? Give feedback.
-
Having the exact same issue here. |
Beta Was this translation helpful? Give feedback.
-
Question 💬
Summary
Referencing issue: #6449
As I have mentioned the use case in above issue, fast forwarding today:
I have implemented
next-auth
to get theaccessToken
from the provider and pass the same as argument to my mutation, then use the token generated from our backend on consecutive API calls.The token rotation has been implemented based on the next-auth doc
refresh token rotation
Problem
After 1 min (my token expiry time) if the session is untouched/running in background then probably it calls the api and updates with the new refreshToken and accessToken (works as intended) but when we refresh/reload the page after one minute it signs out of the session.
When I check the terminal, it looks like when I reload the page, the old refreshToken is not getting updated with new refreshToken. It still has the same refreshToken (the one session had before reload) in client but no the issue when we leave the app untouched 😕
Is there any work around for this? Or what am I doing wrong here?
Thanks in advance!
How to reproduce ☕️
here's the
pages/api/[..nextauth].tsx
and this how
_app.tsx
looks like,Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Beta Was this translation helpful? Give feedback.
All reactions