Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved PlayerAccountService.Instance.SignOut() seems to not sign out the player

Discussion in 'Authentication' started by rafalbudziszewski, Aug 27, 2023.

  1. rafalbudziszewski

    rafalbudziszewski

    Joined:
    May 29, 2019
    Posts:
    5
    Hi!
    I am trying to implement Authentication with Unity Player Accounts into my game. Singing in seems to work perfectly fine. The problem is that after calling SignOut() nothing seems to happen to the player's session. The subsequent login-attempt results in an error:
    AuthenticationException: Invalid state for this operation. The player is already signed in.

    I have this behavior even in the demo scene provided with the Authentication package (UPA_SampleScene). The steps would be as follows:

    1. Launch the Demo Scene
    2. Click Continue with Unity
    3. Log in as a Player in the browser
    4. Go back to Unity -> the access token is now displayed
    5. Click Sign-Out -> the access token and buttons disappear
    6. Click Continue with Unity again
    7. Log in as a Player in the browser
    8. Unity throws an error: AuthenticationException: Invalid state for this operation. The player is already signed in
    when trying to execute await AuthenticationService.Instance.SignInWithUnityAsync(PlayerAccountService.Instance.AccessToken);

    Did anyone experience a similar problem? Looking forward to any hints.
    Regards
    Rafal
     
  2. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
  3. rafalbudziszewski

    rafalbudziszewski

    Joined:
    May 29, 2019
    Posts:
    5
    Thank you! That was it!