I’m sure I am missing something silly but when I pass the google id token to Unity Authentication I get the errors:
[Authentication]: Request failed: 401, {“title”:“PERMISSION_DENIED”,“detail”:“validation failed”,“details”:,“status”:401}
WebRequestException: {“title”:“PERMISSION_DENIED”,“detail”:“validation failed”,“details”:,“status”:401}
Below is my code, any help appreciated:
async void Awake()
{
await UnityServices.InitializeAsync();
InitializePlayGamesLogin();
}
void InitializePlayGamesLogin()
{
PlayGamesPlatform.Activate();
}
// Call when login button is pressed
public void LoginGooglePlayGames()
{
Social.localUser.Authenticate(OnGooglePlayGamesLogin);
}
//Check login success
async void OnGooglePlayGamesLogin(bool success)
{
if (success)
{
// Call Unity Authentication SDK to sign in or link with Google.
string idToken = PlayGamesPlatform.Instance.GetUserId();
await SignInWithGoogleAsync(idToken);
}
else
{
Debug.Log("Unsuccessful login");
}
}
async Task SignInWithGoogleAsync(string idToken)
{
try
{
await AuthenticationService.Instance.SignInWithGoogleAsync(idToken);
Debug.Log("SignIn is successful.");
//if sign in successful turn off login screen.
loginScreen.SetActive(false);
}
catch (AuthenticationException ex)
{
// Compare error code to AuthenticationErrorCodes
// Notify the player with the proper error message
Debug.LogException(ex);
}
catch (RequestFailedException ex)
{
// Compare error code to CommonErrorCodes
// Notify the player with the proper error message
Debug.LogException(ex);
}
}