Setup Google OAuth Login in Unity

I tried to follow the tutorial from Unity

I imported GooglePlayGamesPlugin-0.11.01.unitypackage and then, I added the GooglePlayGamesExampleScript, I added Play Games Services configuration resources to my game, I used the client ID from my web application credentials, then I tried again with the client ID from my android credentials, I created a keystore to identify the project and I created an aab build for my project which displays the results in a text box on the screen.

I created a new app on the Google Play Console, created a Play Games Services configuration and set up achievements.

I created Google Cloud OAuth 2.0 Client ID’s for a Web Application and Android Application using my package name and SHA1 fingerprint

I receive no errors and everything resolved well but I do get 42 logs from my Assets\ExternalDependencyManager\

Does anyone know what I may be doing wrong with authenticating with Google Play?

using GooglePlayGames;
using GooglePlayGames.BasicApi;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GPGSManager : MonoBehaviour
{
    [SerializeField] TMPro.TMP_Text content;
    public string Token;
    public string Error;


    // Start is called before the first frame update
    void Start()
    {
        content.text = "Start\n";

        PlayGamesPlatform.Activate();
        PlayGamesPlatform.Instance.Authenticate((success)=>
        {
            content.text += "finished\n"+ success.ToString()+"\n";

            if (success == SignInStatus.Success)
            {
                Debug.Log("Login with Google Play games successful.");
                content.text += "Login with Google Play games successful.";

                PlayGamesPlatform.Instance.RequestServerSideAccess(true, code =>
                {
                    Debug.Log("Authorization code: " + code);
                    content.text += "Authorization code: " + code;
                    Token = code;
                    // This token serves as an example to be used for SignInWithGooglePlayGames
                });
            }
            else
            {
                Error = "Failed to retrieve Google play games authorization code";
                Debug.Log("Login Unsuccessful");
                content.text += "Login Unsuccessful";
            }
        });
    }
}

So, it turns out that you cannot activate Google Play while editing. You must build and run your game on a cellular device with an android operating system installed. This means that debugging is completely useless so you will need to create an onscreen text box to debug that way with a 5 minute wait time between runs. At least you do not need to publish your app on the Google Play console for this to work.

Edit, I was wrong. While I can authenticate with Google, I still cannot use

PlayGamesPlatform.Instance.RequestServerSideAccess(true, code =>
                {
                    Debug.Log("Authorization code: " + code);
                    content.text += "Authorization code: " + code;
                    Token = code;
                    // This token serves as an example to be used for SignInWithGooglePlayGames
                });

Because nothing details how to set up the web client ID or in what order to share the multiple auto generated credential SHA1’s created

Let me know how you go with this, I can get the auth code but then no idea how to get the google play id from it on the php side of things.

Hey, we actually have an ongoing discussion on this thread about google play sign in. One user so far as a work around for the time being.

I suggest you keep your discussion in your current open thread so that we don’t get lost with what’s happening.

But basically we are working on improving the documentation.

Any progress on this? Updating the engine from 2019.3.3f1 to any of the current stable releases on my project has been an absolute shit show for Google Play Services and Google Ads on Unity.

The Google Sign In Plugin for unity is unmaintained for last 6 years, and you need to do some workaround to make it work.

So, to implement the google sign in I recommend using Oauth2.0. There is a free plugin called “i5 Toolkit For Unity” which you can use to implement the OAuth2.0.

After you authenticate your user with the OpenID, you can get a token from the callback and use that token to authenticate your user to other services, for example firebase.

I have created a step by step process on how to do it. Sharing it here as well in case anyone interested.