Is Signed In

I started this code but it doesn’t work. I still get “The Player is already signing in.”

bool isSignedIn = AuthenticationService.Instance.IsSignedIn;
Debug.Log($"Is Signed In:{isSignedIn}");

if (!isSignedIn)
{
    await AuthenticationService.Instance.SignInAnonymouslyAsync();
}

Does anyone have the correct code or can tell me what I need to change?

Hello
The most likely reason is that this code is being called multiple times
Are you calling this from a method that is called multiple times (like a monobehaviour ‘Update’)?

It likely works as expected the first time but subsequent calls happen as the original operation isn’t completed and you get the error “The Player is already signing in.”

I get false every time I check if a user is signed in, even if it says “The player is already signed in” I have a few scripts that check if a key exists or save an object to Cloud Save and this code is in the Awake or Start methods.

Is this the only place in your project where you call the signin method?
Is there only one instance of that monbehaviour in your scene(s)?
Can you provide more of your sample code?

So I have a cloud save script that checks if a key exists and I do this multiple times. I also do this for saving stuff to cloud save which is done multiple times.

public async override void OnEnter()
{
    await UnityServices.InitializeAsync();
    bool isSignedIn = AuthenticationService.Instance.IsSignedIn;
    Debug.Log($"Is Signed In:{isSignedIn}");

    if (!isSignedIn)
    {
        await AuthenticationService.Instance.SignInAnonymouslyAsync();
    }
if (!key.IsNone && !key.Value.Equals(""))
{
    await ListAllKeys();  
}
}

Everytime I run this Debug.Log($"Is Signed In:{isSignedIn}"); this returns false.

Do we have any idea why this isn’t working ^^^ @erickb_unity

I’m not sure why this isn’t working, you should see error logs if any of the operations failed

Seeing how and where this function is called would also help