Google Play Services authentication problem. Failing to sign in !

Hi,

I am just testing the google play services with a simple Unity project to understand how google play services work so when I decide to integrate these services in the game that I am developing I know what I should do. So, I created an empty project in Unity and added one button for sign in and a text to display the message if the authentication was successful or failed. Then i downloaded google play services plugin for unity from github and imported the package in my project. The I went to google play console and created a new application step by step until everything turned green and ready to publish the game. I created a leaderboard also and then copied the resources from google play console and then in Unity i opened Window>Google Play Games>Setup>Android Setup, pasted the resources and and clicked Setup. Then it was completed. Then used these codes and assigned the text and the function of the sign in button. Here are the codes I am using:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SocialPlatforms;
using GooglePlayGames;

public class Manager : MonoBehaviour {

	[SerializeField]
	private Text authenticationTxt;

	void Start () 
	{
		PlayGamesPlatform.Activate ();
		PlayGamesPlatform.DebugLogEnabled = true;
	}

	public void SignIn()
	{
		if (!Social.localUser.authenticated) {
			Social.localUser.Authenticate ((bool success) => {
				if(success)
				{
					authenticationTxt.text = "Authenticated !";
				}
				else
				{
					authenticationTxt.text = "Failed Authentication";
				}
			});
		}
	}

        //Haven't used this yet...
	public void ShowLeaderboard()
	{
		//...
	}

}

I signed a keystore for my game in Unity and clicked build and run. When I run my game in my device i clicked the sign in button and waited to sign in but the authentication failed. I did include my email as a tester in google play console so this is not the problem. Now I have no idea why the authentication process is failing.

If anyone has encountered this same problem before would be nice to tell me.

Thank you,
Gerald.

I found the solution here

Listen carefully. Copy SHA-1 from “Upload certificate”, not “App signing certificate”. It saved my day.

For me everything (appId , package name , SHA) was correct, but the problem was that I was using silent sign in and google play games was not installed on my phone, hence there was no pop up. When I turned off silent sign in the pop up to install GPG came up and the sign in was successful.

Silent sign in doesn’t work when GPG is not installed.

I was getting “Authentical Cancelled” and solved it via this post:

https://forum.unity.com/threads/google-play-services-not-working.485322/#post-3210077


basically, it occured because I allowed google to sign the application with its own key. It was apparent after I went to GooglePlayConsole-> Release Management → App Signing.

“App Signing by Google Play is enabled for this app”.


Because it was enabled, I had to bother about another web page “Google APIs”.
In there, I had to choose “My Game” from the dropdown in the ribbon, went into Credentials Tab and created a new credential with the appropriate SHA-1.

But the link (in this answer) explains it in more detail.

You can check my article to sign in with google:

Hey if you are still facing this issue in 2021 like I did make sure that you have multiple sha1 keys registered in Google Cloud Platform.

At some point Google started to sign the store apk with their own sha1 which only work when you download the game from the store. Meaning when you sign our local test version with the key you’ve created in Unity, this version will not connect with Google Play Services and will give you the dreaded and very unspecific error SIGN_IN_REQUIRED.

You need to register:
1 key for your local testing
1 key for your distribution through Google Play

Heres more detailed info: https://github.com/playgameservices/play-games-plugin-for-unity/issues/1805#issuecomment-743807887