How can I check if the auth refresh token has expired when the server restarts?

Hello all
When Nakama restart, current user session on Unity client will throw exception: auth token invalid when communicate with Nakama.
How can i detect and resolve this issue and have a seamless user experience ?

Hey @kafka, great question.

I’m assuming you’re talking about your refresh token since those will invalidate when the server responds.

What you’ll want to do is check if the refresh token has expired using session.IsRefreshExpired. You’ll then need to ask the user to reauthenticate.

1 Like

Im having a similar issue in Godot. How would we go about making sure the token doesnt stay open when the server shuts down so it can give the authentication a new token every time someone logs in?

Hey @mojoyup1528 there are two tokens – an auth (short-lived) and a refresh token (long-lived). The refresh token and a fresh auth token are obtained on authentication. The Godot client will automatically refresh the auth token when its close to expiring. But you’ll still need to check is_refresh_expired on your session and reauthenticate when the refresh token is close to expiring.

Oh ok great! So all I need to do then is simply code a check for that with maybe an if statement or something. And do an error check prob.