Unity Play Services Cannot Authenticate

Unity Play Services Cannot Authenticate

So, you've successfully imported the Google Play Games for Unity plugin, followed all of the instructions to a T.

But, when you make a call to sign in to the Play Games using this line of code:

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

...you either get an error saying authentication failed, or the logging in pop over / activity opens up, then suddenly closes again without warning. What to do?

This is usually due to the SHA-1 Upload Certificate in your app (Google Play Console) does not match the SHA-1 Signing Certificate inside the Google API console.

So, what to do? Just copy the SHA-1 inside Play Console and copy it to the API Console.

First, open Google Play Console. Select your App. Then go to Release Management > App Signing. Inside the Upload certificate section, copy the SHA-1 certificate fingerprint, as per depicted below.

Once you have done that, we're going to paste it to the API Console.

Go to the API Console > Select your project > Click Credentials (left menu bar). Under the oAuth 2.0 client IDs, click on your project.

Then, paste the previous SHA-1 key in the Signing-certificate fingerprint textbox:

Yay, you're done! Play Authentication should work now.

HOWEVER, if you still have problem, then the last thing to do is to look at the oAuth Consent Screen. If you have not submitted or saved a consent screen yet, your authentication will fail (this was what snagged me).