Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Play Games Plugin & Unity Authentication keep failing

Discussion in 'Authentication' started by HerrPascal, Oct 7, 2022.

  1. HerrPascal


    Apr 29, 2020
    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.

    Code (CSharp):
    1.  public void Login(UnityAction callbackSuccess, UnityAction callbackFailure)
    2.         {
    3.             PlayGamesPlatform.Instance.Authenticate(OnLogin);
    4.         }
    6.         void OnLogin(SignInStatus signInStatus)
    7.         {
    8.             if (signInStatus == SignInStatus.Success)
    9.             {
    10.                 Dbg.Log(this, "[CloudSave] [Android Auth] Start ReqestServerSideAccess");
    11.                 PlayGamesPlatform.Instance.RequestServerSideAccess(false, code =>
    12.                 {
    13.                     Dbg.Log(this, "[CloudSave] [Android Auth] Login with Google Play games successful. Authorization code: " + code);
    14.                     _ = SignInWithGoogleAsync(code);
    15.                 });
    16.             }
    17.             else
    18.             {
    19.               ....
    20.             }
    21.         }
    22.         //
    23.         async Task SignInWithGoogleAsync(string idToken)
    24.         {
    25.             if(AuthenticationService.Instance.IsSignedIn)
    26.             {
    27.                 try
    28.                 {
    29.                     await AuthenticationService.Instance.LinkWithGoogleAsync(idToken);
    30.                     Dbg.Log(this, "[CloudSave] [Android Auth] ╰(*°▽°*)╯╰(*°▽°*)╯╰(*°▽°*)╯ Link to account is successful.");
    31.                     m_CallbackSuccess?.Invoke();
    32.                 }
    33.                 //Catch Stuff
    34.             } else
    35.             {
    36.                 try
    37.                 {
    38.                     await AuthenticationService.Instance.SignInWithGoogleAsync(idToken);
    39.                     Dbg.Log(this, "[CloudSave] [Android Auth] SignInWithGoogleAsync is successful.");
    40.                     m_CallbackSuccess?.Invoke();
    41.                 }
    42.                 //...Catch stuff
    43.             }
    44.         }
    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;

    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:
    [Authentication]: Request failed: 401, {"title":"PERMISSION_DENIED","detail":"unable to validate token","details":[],"status":401}

    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!
  2. mahdik_unity


    Unity Technologies

    Sep 16, 2021
    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:

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

    Code (CSharp):
    1. AuthenticationService.Instance.SignInWithGoogleAsync

    Code (CSharp):
    1. AuthenticationService.Instance.LinkWithGoogleAsync
    if you are willing to use GPG v11.01 you can start the fix by using
    Code (CSharp):
    1. AuthenticationService.Instance.SignInWithGooglePlayGamesAsync
    Code (CSharp):
    1. AuthenticationService.Instance.LinkWithGooglePlayGamesAsync
    Last edited: Oct 7, 2022
  3. HerrPascal


    Apr 29, 2020
    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

    I get the error:
    "Requesting Server Side Access Task Failed - Com.Google.Android.GMS.Common.API.APIException 10"
  4. mahdik_unity


    Unity Technologies

    Sep 16, 2021
    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 (

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


    Jan 14, 2015
    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 2.2.0
    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?

    Code (CSharp):
    1.     public void LoginGooglePlayGames()
    2.     {
    3.         PlayGamesPlatform.Instance.Authenticate((success) =>
    4.         {
    5.             if (success == SignInStatus.Success)
    6.             {
    7.                 Debug.Log("Login with Google Play games successful.");
    9.                 PlayGamesPlatform.Instance.RequestServerSideAccess(true, code =>
    10.                 {
    11.                     Debug.Log("Authorization code: " + code);
    12.                     Task task = SignInWithGooglePlayGamesAsync(code);
    13.                 });
    14.             }
    15.             else
    16.             {
    17.                 Debug.Log("Login Unsuccessful");
    18.             }
    19.         });
    20.     }
    22.     public async Task SignInWithGooglePlayGamesAsync(string authCode)
    23.     {
    24.         try
    25.         {
    27.             await AuthenticationService.Instance.SignInWithGooglePlayGamesAsync(authCode);
    28.             Debug.Log("SignIn is successful.");
    29.         }
    30.         catch (AuthenticationException ex)
    31.         {
    32.             Debug.LogException(ex);
    33.         }
    34.         catch (RequestFailedException ex)
    35.         {
    36.             Debug.LogException(ex);
    37.         }
    38.     }
  6. mahdik_unity


    Unity Technologies

    Sep 16, 2021
    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.
  7. dev_duong_nguyenanh


    Oct 12, 2022
  8. charleyCo


    Sep 16, 2019
    Make sure your client id from web client upload_2022-11-17_13-28-10.png
  9. anilozmen


    Nov 11, 2021
    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.
  10. spvn


    Dec 10, 2013
    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...