Auth token invalid unity

Hi, I tried to use the unity snippets NakamaManager.cs and NakamaManagerUsage.cs and it got the error Auth token invalid.

All I did was after creating the project, I attached the snippets to main camera and a new GameObject respectively, and ran the project. It gets error here: var account = await NakamaManager.Instance.Client.GetAccountAsync(session);.

Main Camera:
image

New GameObject:
image

Error messages:

versions:
Unity 2019.4.0f1
Nakama Unity 2.7.0

How would I fix this? Or are there any hints I’m missing?

How would I fix this? Or are there any hints I’m missing?

@gocs By default the game server sets the session token lifetime to 60 seconds. You should set it to the right value that is relevant to your game project. :slight_smile:

-session.token_expiry_sec int
	Token expiry in seconds. (default 60)

You can also set it in the YML file:

session:
    token_expiry_sec: 86400

NOTE: It is intentionally set to 60 seconds to remind game developers to set the value early in the development cycle.

Thank you so much, I did not know about that token_expiry_sec until I found the docker-compose.yml

1 Like

@gocs I think we need to surface this information better in our docs because it comes up a lot. We do mention it in a bunch of places though. I’ll see what we can do to make it clearer. :+1:

1 Like

Is there a preferred way that will prevent the error without altering the expiration flag in Unity?
I’m planning to build the project based from the NakamaManager.cs and NakamaManagerUsage.cs.

@gocs Nope. This is an important setting controlled by the set up of the game server. It would not be useful to make it configurable by game clients. You simply need to add it to how you start the game server either in the docker-compose file or as a cli flag when the server starts.