question

bilu avatar image
bilu asked

Google Failed to Authorize your login

Hello,

I would like to be able to offer users of my app to connect using their goolges account credentials. Here is the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine.SceneManagement;
using TMPro;


public class SetupGPG : MonoBehaviour
{
    public TextMeshProUGUI GoogleStatusText;
    
    void Start()
    {
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
        .AddOauthScope("profile")
        .RequestServerAuthCode(false)
        .Build();
        PlayGamesPlatform.InitializeInstance(config);
        // recommended for debugging:
        PlayGamesPlatform.DebugLogEnabled = true;
        // Activate the Google Play Games platform
        PlayGamesPlatform.Activate();
        /*Social.localUser.Authenticate((success) => {
            if (success)
            {
                PlayGamesPlatform.Instance.GetServerAuthCode();
            }


        });
        OnSignInButtonClicked();*/
    }


    public void OnSignInButtonClicked()
    {
        Debug.Log("clicked");
        Social.localUser.Authenticate((success) => 
        {


            if (success)
            {


                GoogleStatusText.text = "Google Signed In";
                Debug.Log("Google Signed In");
                var serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();
                Debug.Log("Server Auth Code: " + serverAuthCode);


                PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
                {
                    TitleId = PlayFabSettings.TitleId,
                    ServerAuthCode = serverAuthCode,
                    
                    CreateAccount = true
                }, (result) =>
                {
                    GoogleStatusText.text = "Signed In as " + result.PlayFabId;
                    Debug.Log("Signed In as " + result.PlayFabId);


                }, OnPlayFabError); ;
                SceneManager.LoadScene(12);
            }
            else
            {
                GoogleStatusText.text = "Google Failed to Authorize your login";
                Debug.Log("Google Failed to Authorize your login");
            }


        });


        Debug.Log("clicked 2 ");


    }


    private void OnPlayFabError(PlayFabError obj)
    {
        Debug.Log("Not A Success");
    }


}

As for the status of "Google Play Service" in my Play Console account, it says "Published" for more than 10 hours. But when I try this in my app on phones directly I get the message "Google failed to authorize your login".

The account I use to test this in my app is well informed in "Tester".

Is it a code line that could display the exact reason for Google failed to authorize ?
In Playfab, I can see thaht there are a lot of attempt to connect but all failed but there isn't the exact reason why Google not authorize it.

Could you please help me ?

Account Management
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Made Wang avatar image
Made Wang answered

You said you can see the connection failure in PlayFab, is it in GameManager->Data->Data Explorer(basic)? If so, can you provide detailed event data?

The "Google failed to authorize your login" error appears in the error callback of Social.localUser.Authenticate, which is an error returned by the Google SDK. We are not experts in Google, and we suggest that you seek professional support from the Google developer community.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.