How to Fix Error Google Play Games Authentication in Unity Returning Login

I recently spent a few very frustrating days trying to integrate Google Play Games Services authentication into my Unity Android project. What should’ve been a quick setup turned into a rabbit hole of trial, error, debugging, and learning. So I’m writing this blog post to share my experience from the initial setup, to getting hit with the dreaded “Login Unsuccessful: Canceled” error, and finally arriving at a working solution with some added functionality.

My First Attempt

I started with the default authentication code from Unity’s integration with the Google Play Games plugin. Here’s what it looked like:

using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine;

public class GooglePlayGamesExampleScript : MonoBehaviour
{
public string Token;
public string Error;

void Awake()
{
// Initialize PlayGamesPlatform
PlayGamesPlatform.Activate();
LoginGooglePlayGames();
}

public void LoginGooglePlayGames()
{
PlayGamesPlatform.Instance.Authenticate((success) =>
{
if (success == SignInStatus.Success)
{
Debug.Log("Login with Google Play games successful.");

PlayGamesPlatform.Instance.RequestServerSideAccess(true, code =>
{
Debug.Log("Authorization code: " + code);
Token = code;
});
}
else
{
Error = "Failed to retrieve Google play games authorization code";
Debug.Log("Login Unsuccessful" + success);
}
});
}
}

At first glance, it looked clean. I expected this to “just work.” But when I ran it on my Android device, I got:

Login Unsuccessful: Canceled
[Play Games Plugin] ERROR: Returning an error code.

Login Unsuccessful Cancel Error

I had no idea why it was being canceled, not failed. So I started digging into all possible causes. Here’s what I found:

Common Issues That Can Trigger This Error

  • OAuth Client ID mismatch: I had used the wrong SHA1 or keystore during setup. After rechecking, I realized I needed to regenerate the OAuth credentials based on my release keystore.
  • Not listed as a test user: If your Google account isn’t added as a tester in Google Play Console > Play Games Services > Configuration > Testers, you will hit a wall.
  • Sideloading instead of internal testing: I was installing my APK via ADB, which skips the proper handshake with Play Store. The fix? Upload it to Internal Testing and install it from there.
  • Not signed into Google Play Games on the device: You have to make sure the device is signed in to the Google Play Games app with the test account.
  • Outdated or misconfigured plugin: I updated to the latest Google Play Games plugin and re-imported the google-services.json and resources files just to be safe.

Final Working Version

After resolving the setup issues, I wanted to make the script more robust and interactive. So I added a UI-based approach for debugging and retrying login attempts. Here’s the final version I ended up using:

Editusing GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine;
using UnityEngine.UI;

public class GooglePlayGamesExampleScript : MonoBehaviour
{
public Text statusText; // Assign this in Unity UI
public Button signInButton;

public string Token;
public string Error;

private void Start()
{
ConfigurePlayGames();
signInButton.onClick.AddListener(LoginGooglePlayGames);
}

private void ConfigurePlayGames()
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.RequestServerAuthCode(false)
.RequestEmail()
.Build();

PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true; // Extra logging
PlayGamesPlatform.Activate();

statusText.text = "Play Games Configured. Click Sign In.";
}

public void LoginGooglePlayGames()
{
statusText.text = "Attempting to sign in...";
PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptAlways, (status) =>
{
if (status == SignInStatus.Success)
{
statusText.text = "Sign-in successful!";
Debug.Log("Login successful.");

PlayGamesPlatform.Instance.RequestServerSideAccess(true, code =>
{
Token = code;
Debug.Log("Authorization code: " + code);
});
}
else
{
statusText.text = $"Sign-in failed: {status}";
Error = "Google Play Games Auth failed: " + status;
Debug.LogWarning("Login Unsuccessful: " + status);
}
});
}
}

Unity Setup Steps

To make this work inside Unity:

  1. Add a Canvas with:
    • A Text element (assign to statusText)
    • A Button (assign to signInButton and label it “Sign In”)
  2. Upload the app to Internal Testing and install via the Play Store link.
  3. Use the correct SHA1 fingerprint and OAuth Client ID.
  4. Ensure your Google Play Games plugin is up to date and linked to your Unity project correctly.

Bonus Debugging Tips

  • Enable extra logging with:
PlayGamesPlatform.DebugLogEnabled = true;
  • Use Logcat to inspect runtime output:
adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG
  • Avoid emulators authentication often fails on them due to missing Google Play Services features.

Final Thought

After spending almost four days stuck with Google Play Games login errors, I finally cracked the code both figuratively and literally. The problem wasn’t in the Unity code alone but in how everything around it was configured: SHA keys, test accounts, plugin versions, and install methods. If you’re getting “Login Unsuccessful: Canceled,” don’t just stare at your script start double-checking your Google Play Console, OAuth settings, and test environment.

Related blog posts