You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get the new token and eventually the error, so everything is working fine up to here.
on the client I'm using useSession() on a layout component that I share with all the pages:
const{data: session}=useSession()useEffect(()=>{if(session?.error==='RefreshAccessTokenError'){signIn()// Force sign in to hopefully resolve error}},[session])
but when I navigate to any page via Link (next/link), I can see the logs from async session({ session, token }) callback on the terminal whit the correct values, but on the client, session is always the old one, I need to do an hard reload of the page, in order to see the refreshed values
How to reproduce
Expected behavior
to be able to see the new value of useSession() when navigating the site, in order to logout the user if the token expires
The text was updated successfully, but these errors were encountered:
violabg
added
the
triage
Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
label
Mar 29, 2023
Environment
"next": "13.2.4",
"next-auth": "^4.20.1",
Reproduction URL
https://github.com/nextauthjs/next-auth-refresh-token-example
Describe the issue
I'm implementing the refresh token strategy as per the example on https://authjs.dev/guides/basics/refresh-token-rotation#client-side
I'm using credentialProvider, I'm able to obtain a new token and setting it on the jwt callback in [...nextauth].ts
if I console log the session on
I get the new token and eventually the error, so everything is working fine up to here.
on the client I'm using useSession() on a layout component that I share with all the pages:
but when I navigate to any page via Link (next/link), I can see the logs from async session({ session, token }) callback on the terminal whit the correct values, but on the client, session is always the old one, I need to do an hard reload of the page, in order to see the refreshed values
How to reproduce
Expected behavior
to be able to see the new value of useSession() when navigating the site, in order to logout the user if the token expires
The text was updated successfully, but these errors were encountered: