Search Unity

Resolved I can sign-in to UGS when running the build in my computer but not in another with AnonymouslyAsync

Discussion in 'Authentication' started by Nikkolo607, Mar 6, 2023.

  1. Nikkolo607

    Nikkolo607

    Joined:
    Apr 5, 2020
    Posts:
    5
    I've been testing out my game with two builds in my own machine and it works fine. But when I sent the build to a friend for testing, it won´t allow him to sign-in with the SignInAnonymously() function. The code managing the signing is

    Code (CSharp):
    1.    
    2. private async void Start()
    3.     {
    4.  
    5.         await UnityServices.InitializeAsync();
    6.        
    7.         if(!AuthenticationService.Instance.SessionTokenExists)
    8.         {
    9.             return;
    10.         }
    11.         try
    12.         {
    13.             await AuthenticationService.Instance.SignInAnonymouslyAsync();
    14.         }
    15.         catch(AuthenticationException ex)
    16.         {
    17.             Debug.Log(ex);
    18.         }
    19.  
    20.     }
    Its basically a copy from what the documentation recommends for signing players even if cached already, so i don´t really get why it wouldn´t work in another computer.
     
  2. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Hi Nikkolo607
    Would it be possible to share the full script?
    Additionally can you share what versions of the Unity Editor + Unity Authentication package you are using?
     
  3. Nikkolo607

    Nikkolo607

    Joined:
    Apr 5, 2020
    Posts:
    5
    Unity Editor is 2021.3.18f1, and Unity Authentication is 2.4.0, full code of the Relay Network Manager below. For context, I have a button that just runs JoinRelay(text) and uses the text writen inside an InputField, when it's pressed the "player isn't signed in" exception ocurrs.
     

    Attached Files:

  4. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Thanks for providing that script.

    Would you be able to remove the if statement that checks for SessionToken?
    lines 22-25 in your code.

    Could you try building the sample included included in the package manager for authentication and sending that over to your friend for testing? If that signs in successfully then we know it may be something in the code that I may be missing.

    If that also fails I would begin thinking something on the second computer is blocking any communications with Authentication.

    You can find the sample under UNITY EDITOR > WINDOW > AUTHENTICATION > SAMPLES

    upload_2023-3-9_15-57-30.png

    Let me know how that goes.
     
    Nikkolo607 likes this.
  5. Nikkolo607

    Nikkolo607

    Joined:
    Apr 5, 2020
    Posts:
    5
    Forgot to answer, removing the if statement solved the problem! Thank you! The exception wasn´t the problem Im guessing, but the if statement was shutting down the rest of the code immediately