Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kevyntime
Copy link

This pull request adds a refresh_token argument to NakamaClient.restore_session, allowing sessions to be refreshed directly from a restored state. Previously, using client.session_refresh_async(session) on a restored session would result in a Refresh token is required error.

Key Changes:

  • Updated NakamaClient.restore_session to accept a refresh_token.
  • Modified README.md to demonstrate the new functionality.

Fixes: #207

@CLAassistant
Copy link

CLAassistant commented Apr 13, 2024

CLA assistant check
All committers have signed the CLA.

# 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):

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.
Copy link
Contributor

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..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incomplete Session Restore
4 participants