Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question SignInAnonymouslyAsync Token expire error using Remote Config

Discussion in 'Authentication' started by Max_power1965, Aug 18, 2022.

  1. Max_power1965

    Max_power1965

    Joined:
    Oct 31, 2013
    Posts:
    124
    Hello,
    I'm using the following code to initialize the remote config :

    Code (CSharp):
    1. private static async Task InitializeRemoteConfigAsync()
    2.     {
    3.         if (UnityServices.State == ServicesInitializationState.Uninitialized)
    4.         {
    5.  
    6.             try
    7.             {
    8.                 await UnityServices.InitializeAsync();
    9.             }
    10.             catch (Exception ex)
    11.             {
    12.                 Debug.LogError("Unity service autentication faled in InitializeRemoteConfigAsync methos. Error " + ex.Message);
    13.             }
    14.             // initialize handlers for unity game services
    15.        
    16.         }
    17.  
    18.         // options can be passed in the initializer, e.g if you want to set analytics-user-id or an environment-name use the lines from below:
    19.         // var options = new InitializationOptions()
    20.         //   .SetOption("com.unity.services.core.analytics-user-id", "my-user-id-1234")
    21.         //   .SetOption("com.unity.services.core.environment-name", "production");
    22.         // await UnityServices.InitializeAsync(options);
    23.  
    24.         // remote config requires authentication for managing environment information
    25.         if (!AuthenticationService.Instance.IsSignedIn)
    26.         {
    27.  
    28.             try
    29.             {
    30.                 await AuthenticationService.Instance.SignInAnonymouslyAsync();
    31.             }
    32.             catch (Exception ex)
    33.             {
    34.                 Debug.LogError("SignInAnonymouslyAsync in InitializeRemoteConfigAsync methos. Error " + ex.Message);
    35.             }
    36.  
    37.         }
    38.     }
    Everything works fine on the Editor, I'm also able to retrieve the data from the remote Config backend, the problem is when I built on the device where I get the error that you can find attached, What I'm doing wrong?
    If remove the authentication code, the Remote config seems to work fine but I have a lot of warnings says:
    uth Service not initialized.
    Request might result in empty or incomplete response
     

    Attached Files:

  2. saadk_unity

    saadk_unity

    Unity Technologies

    Joined:
    Oct 15, 2021
    Posts:
    6
    Hello,

    I noticed from the screen shot that the system date is set to four days ahead (22-08-22) Can you confirm this? If so you will need to set the device date to the current date as we validate player time on the client side.

    Hope that helps!
     
  3. Max_power1965

    Max_power1965

    Joined:
    Oct 31, 2013
    Posts:
    124
    Thanks that solved the problem, I was testing the local push notification and I had to change the date of the device
     
  4. Mest

    Mest

    Joined:
    Nov 7, 2012
    Posts:
    14
    Hey guys,
    is there a way to manually set date/time of the AuthenticationService to prevent this in general?

    We already verifying our own time (server-side), so our game is not affected if a user is manipulating his device-time (for whatever reason).