Trying to implement in Unity Google Play Games Services

Let’s start…
APP NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY SERVICES

The script (I then call the functions from it in the game):

using System;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using GooglePlayGames.BasicApi.SavedGame;
using UnityEngine;

public static class GPGSAPI
{
    public const string saveName = "SAVE";

    public static bool IsAuth {
        get
        {
            if (PlayGamesPlatform.Instance != null)
                return PlayGamesPlatform.Instance.IsAuthenticated();
            return false;
        }
    }

    public static ISavedGameMetadata game;
    public static ISavedGameClient client;

    public static DateTime startDateTime;

    public static void Initialize(bool debug)
    {
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
            .EnableSavedGames()
            .RequestEmail()
            .RequestServerAuthCode(false)
            .RequestIdToken()
            .Build();
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.DebugLogEnabled = debug;
        PlayGamesPlatform.Activate();
        startDateTime = DateTime.Now;
    }

    public static void Authenticate(bool mode, Action<bool> result)
    {
        PlayGamesPlatform.Instance.Authenticate((obj) =>
        {
            if (obj) client = PlayGamesPlatform.Instance.SavedGame;
            result(obj);
        }, mode);
    }

    public static void GetAchievement(string id, Action<bool> result)
    {
        Social.ReportProgress(id, 100.0f, result);
    }

    public static void SetScoreToLeaderboard(string id, long score, Action<bool> result)
    {
        Social.ReportScore(score, id, result);
    }

    public static void ShowAchievementUI()
    {
        Social.ShowAchievementsUI();
    }

    public static void ShowLeaderboardsUI()
    {
        Social.ShowLeaderboardUI();
    }

    public static void SignOut()
    {
        PlayGamesPlatform.Instance.SignOut();
    }

    public static void OpenSave(Action<SavedGameRequestStatus, ISavedGameMetadata> result)
    {
        if (!IsAuth)
        {
            result(SavedGameRequestStatus.AuthenticationError, null);
            return;
        }
        client.OpenWithAutomaticConflictResolution(saveName, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseLongestPlaytime, result);
    }

    public static void ReadSave(Action<SavedGameRequestStatus, byte[]> result)
    {
        if (!IsAuth)
        {
            result(SavedGameRequestStatus.AuthenticationError, null);
            return;
        }
        OpenSave((st, md) =>
        {
            if (st == SavedGameRequestStatus.Success)
            {
                client.ReadBinaryData(md, result);
                game = md;
            }
            else result(SavedGameRequestStatus.InternalError, null);
        });
    }

    public static void WriteSave(byte[] data, Action<bool> result)
    {
        if (!IsAuth || data == null || data.Length == 0)
        {
            result(false);
            return;
        }
        TimeSpan curSpan = DateTime.Now - startDateTime;
        Action onDataWrite = () =>
        {
            TimeSpan totalPlayTime = curSpan + game.TotalTimePlayed;
            SavedGameMetadataUpdate.Builder builder = new SavedGameMetadataUpdate.Builder()
                .WithUpdatedDescription("Save at " + totalPlayTime.ToString())
                .WithUpdatedPlayedTime(totalPlayTime);
            SavedGameMetadataUpdate update = builder.Build();
            client.CommitUpdate(game, update, data, (s, m) =>
            {
                if (s == SavedGameRequestStatus.Success)
                {
                    game = m;
                    result(true);
                }
                else
                    result(false);
            });
            startDateTime = DateTime.Now;
        };
        if (game == null)
        {
            OpenSave((s, m) =>
            {
                if (s == SavedGameRequestStatus.Success)
                {
                    game = m;
                    onDataWrite();
                }
                else result(false);
            });
            return;
        }
        onDataWrite();
    }
}

Two credentials in the Google Play Console: one with a simple key, the other with a key that GP (Google Play, I will write this way) signs applications. 50 achievements, 3 ratings. I tried to download from GP, installed APK right after assembly, cleaned the data of GP games, / u003 before APP_ID is.
The Web Client ID comes from a regular key, it doesn’t work on a regular one either. I catch an error when it auntithicates. I don’t know what he needs. I recreated the accounts several times. Also I have GoogleMobileAds plugin and Unity IAP.

HELP!!!

Hello, I dont know if this will work but did you configured the google play plug in via
Window > Google Play Games > Setup ?

Why sign in fails?

For Google Play Services to sign in successfully, you need to make sure the apk from where you are logging in should be allowed to make requests to google servers.

How to make the APK authorized to make requests to google servers?

Each apk built with a keystore has a SHA fingerprint. You need to make sure the SHA fingerprint is added in the google cloud.

You can fetch it with keytool command (check here on how to get SHA for each environment )

How many SHA fingerprints I need to add for successful authentication?

In Unity,

  1. Development build uses android default debug keystore.

  2. Release build uses the keystore you set in publishing settings of player settings

  3. Google play store build which uses google play signing.

So in total 3 environments (dev, release and production). If you want all the above builds to authenticate successfully, add all 3 fingerprints.

How to get each environment’s SHA?

  1. Debug ( keytool -list -v -keystore “PATH_TO_DEBUG_KEYSTORE” -alias androiddebugkey -storepass android -keypass android)

  2. Release (Get from Google play console → Your App → Setup → App signing → Upload key certificate )

  3. Apk/AAb downloaded from Google play store (Get from Google play console → Your App → Setup → App signing → App signing key certificate )

Where to add these SHA fingerprints?

Google Play Console. Check here for details on how to add a SHA fingerprint.

Taken from CrossPlatformNativePlugins 2.0 : Essential Kit

Usually the oAuth configuration needs “some days”(they do not say exactly how many) to get work, for me was 13 days until it begins to work in my last project.

You can publish the OAuth consent for now as testing mode is pretty buggy.