Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Automatic authentication? What is the point of the Session Token?

Discussion in 'Authentication' started by Calthies4, Aug 5, 2022.

  1. Calthies4


    Jan 18, 2017
    I've been working on implementing Google sign in with my game, with the main goal being to allow cross platform cloud saves. Starting with a windows desktop app because that is the simplest.

    I got sign in with Google to work... however now that I have that working, I have a number of questions. I was expecting there to be some mechanism to allow you to automatically sign in a user, assuming they have signed in before and linked their google account. I wouldn't want a user to have to manually sign in every time the start up my game. I don't see anything in the documentation or authentication methods to support this.

    Am I supposed to store their google ID token locally, then pass that in to the sign in method on start up of the game? I figured there would be a built in way to handle things like this, so I've been hesitant to start building my own solution for something like that. If this is something the developer is expected to handle themselves, I think it would be helpful to indicate that in the documentation, and maybe even provide an example or design pattern to follow.

    On the same note, I thought that maybe the Session Token stored in PlayerPrefs would be useful in some way for logging the user in again, or something similar. However, I haven't been able to find a use for the session token, and the documentation is unclear on what it is used for. All it mentions is where it is stored in PlayerPrefs. Can someone enlighten me on what the point of the session token is? I assume it has to have some use beyond merely indicating that the user has a valid session due to the fact that it is stored in PlaeyerPrefs.
  2. MiTschMR


    Aug 28, 2018
    I assume storing the session token locally is the way to go, because I haven't yet found a way around that either. I hope someone from Unity (or of course any other knowledgeable person) is able to bring some light into the darkness.
  3. SebT_Unity


    Unity Technologies

    Jun 21, 2021
    Hi there,
    Thanks for taking the time to post on the forums.

    When you have a moment please visit the following link:
    Using the method below SignInAnonymouslyAsync() should attempt to sign you back into previously signed into google accounts. “If a player has already signed in before, the SignInAnonymouslyAsync() method recovers the existing credentials of a user whether they signed in anonymously or through a platform account. If there is no user sign-in information, this method creates a new anonymous user.”

    You can see the overall sign in logic on the following page:

    Please let me know if this isn't clear, Or have any trouble getting this to work. We would love your feedback and how we can improve the documentation.

    Additional links that may be of interest.