heroiclabs / nakama-godot

Godot client for Nakama server written in GDScript.
Apache License 2.0
607 stars 72 forks source link

Incomplete Session Restore #207

Open kevyntime opened 6 months ago

kevyntime commented 6 months ago

I am running into a problem with session management in the Godot 4 client library that seems inconsistent with the session restoration and refresh token handling in other libraries, such as Unity and Unreal.

After authentication, both the auth_token and refresh_token are present, and I save them locally on the user's device. According to the session lifecycle documentation at Nakama Godot Client Library Docs, using NakamaClient.restore_session(auth_token) should restore a session. However, this method returns a NakamaSession instance without a refresh_token. If the session is expired, the next part of the example await client.session_refresh_async(session) fails with a Refresh token is required error.

Based on the body of the restore_session function and the counterpart functions in other client libraries, to workaround this, I've directly instantiated the session with both tokens: var session = NakamaSession.new(auth_token, refresh_token). This approach seems to work correctly.

Am I headed in the right direction with this or is it not meant to work this way? I've just started with Nakama and multiplayer in general, so I'm not really certain what to expect or look for.

lugehorsam commented 6 months ago

Hey @kevyntime you are absolutely right -- could you submit a PR to our SDK with a new NakamaClient.restore_session(auth_token, refresh_token) method?