Play Games Plugin & Unity Authentication keep failing

Hello there.
I’m currently trying to setup an android user login using the Play Games Services Plugin & Unity Authentication package but it keeps on failing. Below you can see the current code.

 public void Login(UnityAction callbackSuccess, UnityAction callbackFailure)
        {
            PlayGamesPlatform.Instance.Authenticate(OnLogin);
        }

        void OnLogin(SignInStatus signInStatus)
        {
            if (signInStatus == SignInStatus.Success)
            {
                Dbg.Log(this, "[CloudSave] [Android Auth] Start ReqestServerSideAccess");
                PlayGamesPlatform.Instance.RequestServerSideAccess(false, code =>
                {
                    Dbg.Log(this, "[CloudSave] [Android Auth] Login with Google Play games successful. Authorization code: " + code);
                    _ = SignInWithGoogleAsync(code);
                });
            }
            else
            {
              ....
            }
        }
        // https://docs.unity.com/authentication/PlatformSignInGooglePlayGames.html
        async Task SignInWithGoogleAsync(string idToken)
        {
            if(AuthenticationService.Instance.IsSignedIn)
            {
                try
                {
                    await AuthenticationService.Instance.LinkWithGoogleAsync(idToken);
                    Dbg.Log(this, "[CloudSave] [Android Auth] ╰(*°▽°*)╯╰(*°▽°*)╯╰(*°▽°*)╯ Link to account is successful.");
                    m_CallbackSuccess?.Invoke();
                }
                //Catch Stuff
            } else
            {
                try
                {
                    await AuthenticationService.Instance.SignInWithGoogleAsync(idToken);
                    Dbg.Log(this, "[CloudSave] [Android Auth] SignInWithGoogleAsync is successful.");
                    m_CallbackSuccess?.Invoke();
                }
                //...Catch stuff
            }
        }

The PGS Plugin itself seems to work fine. I see the UI and my User when I start the application. The PGS Authenticate method call also seems to work fine - it logs “Authentication Succeeded”.
Now the RequestServerSideAccess call returns
“Requesting Server Side Access Task Failed - Com.Google.Android.GMS.Common.API.APIException 10”
and the resulting authcode is empty. Therefore the LinkWithGoogleAsync or SignInWithGoogleAsync method calls are returning “no token provided” errors.

I also tried to get the User ID via
var id = ((PlayGamesLocalUser)PlayGamesPlatform.Instance.localUser).id;
and
var userID = PlayGamesPlatform.Instance.GetUserId();From there I get my userID A_XXXXXX… but it seems like this is not what the Authentication methods need. I get the following error msg:

I also tried Authentication.instance.Link/SignInWithGooglePlayGamesAsync - same error.

From my point of view I set everything up how it should be:
I installed the authentication 2.2.0 via the package manager.
I Installed the Play Games Services Plugin 0.11.01
I did set it up how the documentation told me. I added the Android Resources from the play console and I also provided a web app client id.

In the play console I configured the play games services and added/linked OAuth 2.0-Client-IDs via the Google Cloud platform. Both SHA1 keys (Signing & Upload) I get from the play console app integrity page are linked where they’re supposed to be. I pasted the signing key in the OAuth credentials and the upload key is in the keystore file in Unity.
Whenever I test the integration I build an aab via the Unity Editor and upload it to our internal test track where I’m registered as a tester.

I did a lot of google & unity forum research regarding this issue but nothing I found was able to help me. I hope that maybe someone here has any ideas on what could be the problem. Thank you!

Hello @HerrPascal ,
Please note that Google Play Games authentication is different from Google authentication. Please check the google play games compatibility with the id providers in the docs

Details can be found here:
https://docs.unity.com/authentication/PlatformSignInGooglePlayGames.html
https://docs.unity.com/authentication/PlatformSignInGoogle.html

I see you are using Google Play Games Services plugin v11.01, while calling

AuthenticationService.Instance.SignInWithGoogleAsync

and

AuthenticationService.Instance.LinkWithGoogleAsync

if you are willing to use GPG v11.01 you can start the fix by using AuthenticationService.Instance.SignInWithGooglePlayGamesAsync
and AuthenticationService.Instance.LinkWithGooglePlayGamesAsync instead

1 Like

Hello @mahdik_unity
Thanks for the reply! Like I mentioned, I already tried the XWithGooglePlayGamesAsync methods and I get the same error. Also I assume the “main” problem occurs before I even use the Authentication calls, but when I call
PlayGamesPlatform.Instance.RequestServerSideAccess
I get the error:
“Requesting Server Side Access Task Failed - Com.Google.Android.GMS.Common.API.APIException 10”

hello @HerrPascal
thanks for the follow up. it seems to be an issue with Google Play Games plugin. Can you try this piece of code?
Set up a Google Play Games sign-in (unity.com)

if it still doesn’t work, I recommend you check with Google why you haven’t been able to call the RequestServerSideAccess api

Hi, when i run my game in android the authorization token code show correct in the log, but
AuthenticationService.Instance.SignInWithGooglePlayGamesAsync return error 401 unable to validate token. PERMISSION_DENIED

I use the code from Set up Google Play Games sign-in and

com.unity.services.authentication 2.2.0
GooglePlayGamesPlugin-0.11.01
Unity 2021.3.11f1c2

I setup ID de client and secret, and the web app credential

I’ve been on this all day, am I doing something wrong?

    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);
                    Task task = SignInWithGooglePlayGamesAsync(code);
                });
            }
            else
            {
                Debug.Log("Login Unsuccessful");
            }
        });
    }

    public async Task SignInWithGooglePlayGamesAsync(string authCode)
    {
        try
        {

            await AuthenticationService.Instance.SignInWithGooglePlayGamesAsync(authCode);
            Debug.Log("SignIn is successful.");
        }
        catch (AuthenticationException ex)
        {
            Debug.LogException(ex);
        }
        catch (RequestFailedException ex)
        {
            Debug.LogException(ex);
        }
    }
1 Like

Hello @gferrari

would you be able to send me a private message with your project id and your org? This would allow me to debug and solve the issue.
Thanks

Hello @mahdik_unity
Im facing same issue as @gferrari
Would you mind help me with that

1 Like

Make sure your client id from web client

3 Likes

I was facing the same issue, IDs and all the logic were correct. I tried many things to resolve the issue.
I was using authentication v2.2.0 and Play Games Services Plugin v0.11.01.

I removed all GooglePlayGames library from the project and reimported all, used a custom ID class name while setting up Play Games Plugin, and reconfigured PlayGames login credentials in player settings. In addition, I updated the authentication library to v2.3.1 version. It is working as expected. Hope it helps guys.

how the heck do you have the Web Client that’s auto created by Google Service? I’ve seen it generated before for an older project that used Firebase but now that I’m trying to setup with UGS I don’t have this web client credential being created…

1 Like

Same problem in 2023 :frowning:

I don’t remember but you can create it yourself :slight_smile:

@HerrPascal
any fix? i face problem like you, i dont know how to fix it. i was searching all days night and found 0 solution.

Same problem here!!!

Same.

I’m running into this as well. I’ve set Google Play Games Services with other games and don’t remember having this issue. I’ve tried 3 client ids:

  • “Web client (auto created by Google Service)”, which was of type “Web Application”
  • A client id of type “Android”
  • A client id that I created manually, of type “Web Application”

I also published my changes in the Google Play Games console, in case they needed to be live before authentication would work properly.

In all permutations, I see the same messages in logs:

2024/05/20 18:12:58.776 19122 19144 Warn Unity *** [Play Games Plugin 0.11.01] 05/20/24 18:12:58 -07:00 ERROR: Returning an error code.

I’m running out of ideas. Anyone find a solutions?

Pay close attention to which certificate fingerprint you use in the OAuth credential. There are 2 different ones to choose from: the Upload Key (which signs the app when you build it) and the App Signing Key (which Google uses to sign the app when it distributes it).