#next-auth callback and JWT confusion

8 messages · Page 1 of 1 (latest)

fickle zephyr
#

I am using the Spotify credentials provider. I want the exp timestamp on the JWT issued by my site to match the expiry timestamp on the access token issued by Spotify.

Using the next-auth package, the jwt() and session() callbacks are fired every time I leave the tab and return to it. Is this the intended behavior? Further, every time this happens, the iat and exp timestamps are updated. While I could add another property, I wanted to use the exp property which already exists, but the callbacks run and the timestamps update every time the session is updated. I assume means a new token is being issued. I only want the timestamps to update when the user signs in or the Spotify token is refreshed.

minor dawn
#

Yes, jwt and sess callback are triggered on tab focus. Thats because of the sessioncontwxt provider.

#

You can still check jwt and sess callback whether theyre triggered from signin or just session refresh

#

In jwt you have trigger==="signIn"

fickle zephyr
#

Thanks a ton. That's really useful. As far as the exp value updating, is that default behavior, and is there a way to disable it?

minor dawn
fickle zephyr
#

No worries thanks again!

minor dawn