-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add refresh_token support to NakamaClient.restore_session #208
base: master
Are you sure you want to change the base?
Conversation
# Returns a session. | ||
static func restore_session(auth_token : String): | ||
return NakamaSession.new(auth_token, false) | ||
static func restore_session(auth_token : String, refresh_token: String): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refresh_token
parameter should probably default to ””
for backwards compatibility. It would also be useful for people not using refresh tokens.
``` | ||
|
||
It is recommended to store the auth token from the session and check at startup if it has expired. If the token has expired you must reauthenticate. The expiry time of the token can be changed as a setting in the server. | ||
It is recommended to store the auth token and refresh token from the session and check at startup if it has expired. If the token has expired you can use the refresh token to refresh the session, after which you can save the new tokens. If both tokens have expired, you must reauthenticate. The expiry time of the tokens can be changed as a setting in the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small edit:"...check at startup if they have expired. If the auth token has expired..."
This pull request adds a
refresh_token
argument toNakamaClient.restore_session
, allowing sessions to be refreshed directly from a restored state. Previously, usingclient.session_refresh_async(session)
on a restored session would result in aRefresh token is required
error.Key Changes:
NakamaClient.restore_session
to accept arefresh_token
.Fixes: #207