Hi, I’m getting errors with Google Play Games Authentication. first I tested it with Google Play by itself and it works just fine. so it messes up when I add it with the rest of my sign-in options. error Singleton is not initialized please call UnityServices.InitializeAsync() to initialize. but when I added it before it gave me external token not provided
private void Start()
{
signIn = saveManager.logIn;
StartClientServices();
PlayGamesPlatform.Activate();
PlayerAccountService.Instance.SignedIn += SignInWithUnity;
}
//to see if players are signed in or not and open the auth menu so they can pick their sign options
async void StartClientServices()
{
if (signIn == false)
{
try
{
if (UnityServices.State != ServicesInitializationState.Initialized)
{
var options = new InitializationOptions();
options.SetProfile("Default_Profile");
await UnityServices.InitializeAsync();
}
if (!eventsInitialized)
{
SetupEvents();
}
if (AuthenticationService.Instance.SessionTokenExists)
{
Debug.Log("SessionTokenExists");
SignInWithAnonymously();
}
else
{
//open AuthMenu so player can sign in
authMenuGameObject.SetActive(true);
}
}
catch (Exception e)
{
Debug.LogException(e);
SetErrorMenu(e.Message + "try again");
}
}
else
{
UpdatePlayerName();
SignInConfirmAsync();
}
}
public async void LoginGooglePlayGames()
{
PlayGamesPlatform.Instance.Authenticate((success) =>
{
if (success == SignInStatus.Success)
{
Debug.Log("Login with Google Play games successful.");
PlayGamesPlatform.Instance.RequestServerSideAccess(true, async code =>
{
Debug.Log("Authorization code: " + code);
token = code;
});
}
else
{
SetErrorMenu("Failed to retrieve Google play games authorization code");
Debug.Log("Login Unsuccessful Failed to retrieve Google play games authorization code");
}
});
await SingInWithGooglePlayGamesAsync(token);
}
//Here is were I get the error. Singleton is not initialized please call UnityServices.InitializeAsync() to initialize
async Task SingInWithGooglePlayGamesAsync(string authCode)
{
try
{
await UnityServices.InitializeAsync(); //if I put it here I get: external token not provided
await AuthenticationService.Instance.SignInWithGooglePlayGamesAsync(authCode); await
UnityServices.InitializeAsync();//when I put it here I get the same: Singleton is not initialized
please call UnityServices.InitializeAsync() to initialize
Debug.Log("SignIn is successful.");
UpdatePlayerName();
await CheckForNotifications();
}
catch (AuthenticationException e)
{
Debug.LogException(e);
SetErrorMenu(e.Message);
}
catch (Exception e)
{
Debug.LogException(e);
SetErrorMenu(e.Message);
}
}