Search Unity

Anonymous Sign not working! Not generating Session Token!

Discussion in 'Unity Gaming Services General Discussion' started by Raphn, Aug 6, 2022.

  1. Raphn

    Raphn

    Joined:
    Nov 26, 2019
    Posts:
    1
    Hi, everyone!

    Trying to build my first multiplayer using NetCode and all that new good stuff. But, every time I have the same error when trying to authenticate anonymously. Printing "AnalyticsSessionInfo.identityToken" displays an empty string!

    Errors:
    [Authentication]: Token has expired. [...]
    Unity.Services.Authentication.JwtDecoder:Decode<Unity.Services.Authentication.AccessToken> (string,Unity.Services.Authentication.WellKnownKey[]) (at Library/PackageCache/com.unity.services.authentication@2.1.1/Runtime/Utilities/Jwt/JwtDecoder.cs:51)
    Unity.Services.Authentication.AuthenticationServiceInternal:CompleteSignIn ...
    -----:::::
    RequestFailedException: Failed to decode and verify access token.
    Unity.Services.Authentication.AuthenticationServiceInternal.CompleteSignIn (Unity.Services.Authentication.SignInResponse response, System.Boolean enableRefresh) (at Library/PackageCache/com.unity.services.authentication@2.1.1/Runtime/AuthenticationServiceInternal.cs:504)...

    Code (CSharp):
    1. private async Task Authenticate()
    2.     {
    3.         Debug.Log($"Starting authentication...");
    4.         await UnityServices.InitializeAsync();
    5.  
    6.         Debug.Log($"Signing In Anonymously Async...");
    7.         await AuthenticationService.Instance.SignInAnonymouslyAsync();
    8.     }
     
  2. ItsNoxL

    ItsNoxL

    Joined:
    Dec 13, 2020
    Posts:
    4
    I know this post is a bit old, but I'm running into a similar issue. When I'm trying to authenticate on my machine, everything works as intended. But when I send a build of the game to my friend, he gets the exact same error

    [Authentication]: Token has expired.
    RequestFailedException: Failed to decode and verify access token.

    We are pretty desperate at this point and we even tried installing unity on his pc and writing a short authentication script there. It still didn't work for him. Has anyone found a way to fix it?
     
  3. unity_lKj2L45mNspniw

    unity_lKj2L45mNspniw

    Joined:
    Dec 20, 2019
    Posts:
    8
    im here for the same problem :(
     
  4. davialbuquerque

    davialbuquerque

    Unity Technologies

    Joined:
    Jun 3, 2021
    Posts:
    22
    Hey everyone!
    Prior to the release of Unity Authentication 2.5.0 the SDK would validate the expiration date on the access token on the SDK and would not take into account different timezones and fail the validation. Since the release of 2.5.0 the SDK no longer validates the expiration on the access token on the SDK and leaves the validation to the backend.
    I can see the first report was on version 2.1.0. If you're still having issues would you be able to update to the a version after 2.5.0?