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.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Official Tutorial - Authentication with Google Play Games

Discussion in 'Authentication' started by SebT_Unity, Mar 7, 2023.

  1. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    266
    *Information in this guide is correct from date of upload: 2023/03/07*

    Summary
    This is a step by step authentication tutorial made to simplify the many different pages that are required to set up Google Play Games Authentication.

    More information can be found here.


    Requirements

    Authentication integration with Google Play Games
    Initial Google Play Console setup
    1. Sign in to google play console
    2. Create a new app. *More detailed steps can be found on the official website here
    3. Fill in your app name language and if your application is free or paid
    4. Choose GAME in the app details. *Your application must be type GAME to access the Setup and Management Menu*


    5. Select Create App
    6. Go to Google Play Console > Grow > Play Games Services > Setup and management > Configuration
    7. Choose the appropriate Google API selection for your game eg: No, My game doesn’t use Google APIs
    8. Click on he Create button
    9. Select Setup and Management>Configuration>Credentials>Configure


    10. Select Google Cloud Platform


    11. Next continue configuring Google Cloud Platform
    Google Cloud Platform Setup
    1. Choose if your OAUTH consent is External or Internal.
    2. Select Create
    3. Fill in the *required information
    4. Select Save and continue
    5. Add the following scopes: games,games_lite and drive.appdata

    6. Select Update then Save and continue
    7. Add test users. These should be google accounts associated with Google and Google Play Games
    8. Click on Save and continue, Navigate back go the Google Play Console

    Google Play Console setup continued
    1. [OPTIONAL] If you previously confirmed and configured your oAuth, by following steps 1-8 in the previous section, skip ahead to step 4
    2. Go to Play Games Services > Setup and management > Configuration
    3. Select Configure your oAuth consent screen and confirm configuration
    4. Click on Add Credential to create a credential for Android


    5. Select Type Android
    6. Click Create OAuth client.
    7. Follow the steps proposed below
    8. On Create OAuth Client ID Page - Select the Application Type Android
    9. Name should match the Project Name
    10. Paste your Package Name. * This can be found in the Unity Editor > Edit Project Settings > Player > Android> Other Settings > Package Name.
    11. You must build your project at least once and generate a keystore before moving on to the next step. Learn more here

    12. Open a Command Prompt on Windows or Terminal on a Mac
    13. WINDOWS: *Required to have JDK installed
      1. Generate a SHA-1 key by typing the following into your Command Prompt
        keytool -list -keystore .android\[yourkeystorename].keystore -v
      2. [If the above fails] Generate a SHA-1 by navigating to your JDK installation folder normally located under C:\Program Files\Java\jdk[version]\bin> using the Command Prompt *depending on your JDK installation
        1. Copy your keystore folder path. This is normally generated when create your keystore
        2. Run the following command:
          keytool -list -keystore [keystorefolderpath]\[yourkeystorename].keystore -v
    14. MAC *Required to have JDK installed
      1. Generate a SHA-1 key by typing the following into your Terminal
        keytool -list -keystore ~/.android/[yourkeystorename].keystore -v
      2. [If the above fails] Generate a SHA-1 by navigating to your JDK installation folder normally located under /Library/Java/JavaVirtualMachines/jdk[VERSION] *depending on your JDK installation using the Terminal
        1. Copy your keystore folder path. This is normally generated when create your keystore
        2. Run the following command:
          keytool -list -keystore [keystorefolderpath]\[yourkeystorename].keystore -v
    Example:

    1. Copy the SHA1 key and paste it in the certificate
    2. Create the credentials
    3. Copy your Client ID :[yourid].apps.googleusercontent.com or download the json
    4. Once complete navigate back to the Google Play Console and refresh the credentials page and select your newly created OAuth credentials and save changes
    5. Return to Play Games Services > Setup and management > Configuration
    6. Create a Game Server Credential by clicking Add Credentials in the Configuration page under Setup and management
    7. Select Type Game Server
    8. Select Create OAuth client. Make sure to follow the link proposed
    9. Select Application Type Web Application
    10. Enter Project Name in the Name field
    11. Select Create


    12. Copy your Client ID and Client Secret or download json for future reference
    13. Once complete Refresh OAuth clients in the Google Play Console and select your newly created OAuth credentials and save changes
    14. Go to Play Games Services > Setup and management > Configuration> Credentials and click on Get Resources. Copy the resources
    15. Continue to the next section
    Unity Editor Setup Google Play Games
    1. Download the version v11.01 play-games-plugin-for-unity
    2. Open Unity Editor
    3. Make sure your build settings are set to Android
    4. Import the downloaded file by selecting Assets > Import Package >Custom Package
    5. ***Enable the Auto Android Resolver if you do not have your own
    6. Window > Google Play Games > Setup > Android Setup
    7. Paste your copied xml Resources in the Resources Definition section
    8. Copy the previously saved Web App Client ID and paste it in the field for the Optional Web App Client ID

    9. Select Setup to save

    Unity Authentication Editor Setup
    1. Link your project to a corresponding dashboard project or create a new project id learn more
    2. Select Edit > Project Settings > Services
    3. Select Use an existing Unity project ID
    4. Select corresponding Organization and dashboard project
    5. To install the Authentication Package, Go to Window > Package Manager. Select Unity Registry from the packages drop down menu
    6. Search for Authentication and install the package
    7. To ensure the latest version of authentication click on + > Add package by name and enter com.unity.services.authentication into the field
    8. In the Unity Editor menu, go to Edit > Project Settings > Services > Authentication
    9. From the dropdown menu add Google Play games as an identity provider
    10. Fill in Web App Client ID and Client Secret and save



    Unity Script Setup
    1. Create an empty game object
    2. Create a script, call it GPManager and attach it to the newly created game object
    3. Add the following code to load the authenticated user with google play games and Unity Authentication
      Code (CSharp):
      1. using System;
      2. using GooglePlayGames;
      3. using GooglePlayGames.BasicApi;
      4. using System.Threading.Tasks;
      5. using Unity.Services.Authentication;
      6. using Unity.Services.Core;
      7. using UnityEngine;
      8.  
      9.  
      10. public class GPManager : MonoBehaviour
      11. {
      12.     public string Token;
      13.     public string Error;
      14.  
      15.     void Awake()
      16.     {
      17.         PlayGamesPlatform.Activate();
      18.     }
      19.  
      20.     async void Start()
      21.     {
      22.         await UnityServices.InitializeAsync();
      23.         await LoginGooglePlayGames();
      24.         await SignInWithGooglePlayGamesAsync(Token);
      25.     }
      26.     //Fetch the Token / Auth code
      27.     public Task LoginGooglePlayGames()
      28.     {
      29.         var tcs = new TaskCompletionSource<object>();
      30.         PlayGamesPlatform.Instance.Authenticate((success) =>
      31.         {
      32.             if (success == SignInStatus.Success)
      33.             {
      34.                 Debug.Log("Login with Google Play games successful.");
      35.                 PlayGamesPlatform.Instance.RequestServerSideAccess(true, code =>
      36.                 {
      37.                     Debug.Log("Authorization code: " + code);
      38.                     Token = code;
      39.                     // This token serves as an example to be used for SignInWithGooglePlayGames
      40.                     tcs.SetResult(null);
      41.                 });
      42.             }
      43.             else
      44.             {
      45.                 Error = "Failed to retrieve Google play games authorization code";
      46.                 Debug.Log("Login Unsuccessful");
      47.                 tcs.SetException(new Exception("Failed"));
      48.             }
      49.         });
      50.         return tcs.Task;
      51.     }
      52.  
      53.  
      54.     async Task SignInWithGooglePlayGamesAsync(string authCode)
      55.     {
      56.         try
      57.         {
      58.             await AuthenticationService.Instance.SignInWithGooglePlayGamesAsync(authCode);
      59.             Debug.Log($"PlayerID: {AuthenticationService.Instance.PlayerId}"); //Display the Unity Authentication PlayerID
      60.             Debug.Log("SignIn is successful.");
      61.         }
      62.         catch (AuthenticationException ex)
      63.         {
      64.             // Compare error code to AuthenticationErrorCodes
      65.             // Notify the player with the proper error message
      66.             Debug.LogException(ex);
      67.         }
      68.         catch (RequestFailedException ex)
      69.         {
      70.             // Compare error code to CommonErrorCodes
      71.             // Notify the player with the proper error message
      72.             Debug.LogException(ex);
      73.         }
      74.     }
      75. }
      76.  

    Testing
    Check if authentication is working by using Unity Logcat or Android studio Logcat.
    You must connect your device to your workstation to view the Logcat.
    A successful test will print out the following:

    Unity Logcat (example):




    Android Studio Logcat (example):




    Additionally a visual queue will be displayed upon successful login.



    Conclusion
    This should get you started logging in to authentication and google play games generating and linking a user id between Google and Unity.


    Links for further knowledge

    Authentication documentation for Unity
    https://docs.unity.com/authentication/en/manual/set-up-google-play-games-signin

    Disable automatic sign in
    https://www.hardreset.info/devices/...ble-automatically-sign-in-to-supported-games/
     
    Last edited by a moderator: Mar 27, 2023
    SrNull, aliajami, DankalApps and 15 others like this.
  2. ReflexiveFox

    ReflexiveFox

    Joined:
    Nov 21, 2019
    Posts:
    5
    Julian-Unity3D and SebT_Unity like this.
  3. GainfulSage

    GainfulSage

    Joined:
    Apr 30, 2015
    Posts:
    106
  4. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    189
    Yes, Google Play Games hasn't supported iOS since 2018. However, there are alternatives for sign in with Authentication on iOS devices such as:
    Apple (unity.com)
    and
    Apple Game Center (unity.com)
     
  5. MiguelCoK

    MiguelCoK

    Joined:
    Aug 22, 2017
    Posts:
    12
    Hi, thanks for the step by step guide. It is really helpful to clarify some ambiguities in the official documentation, such as not explicitly saying that you have to create a web credential.

    I have a doubt. My project is open sourced. In the Unity Editor Setup Google Play Games section's steps my appId and client Id got saved in ../ProjectSettings/GooglePlayGameSettings.txt file (see attached image).

    1. What are the consequences of leaving these fields public?
    2. How can I avoid such consequences? if they exist

    Thanks in advance and again for the guide.
     

    Attached Files:

  6. Loomabox

    Loomabox

    Joined:
    Nov 4, 2015
    Posts:
    46
    I spent more than a week before I realized that the problem was in the proguard-user.txt file o_O

    Unity version: 2019.4
    Google Mobile Ads v7.1.0
    Google Play Games v10.12
    Target platform: Android

    If you are using the "Custom Proguard File" option you must add the following lines to your proguard-user.txt file

    -keep class com.google.android.gms.games.PlayGames { *; }
    -keep class com.google.android.gms.games.leaderboard.** { *; }
    -keep class com.google.android.gms.games.snapshot.** { *; }
    -keep class com.google.android.gms.games.achievement.** { *; }
    -keep class com.google.android.gms.games.event.** { *; }
    -keep class com.google.android.gms.games.stats.** { *; }
    -keep class com.google.android.gms.games.video.** { *; }
    -keep class com.google.android.gms.games.* { *; }
    -keep class com.google.android.gms.common.api.ResultCallback { *; }
    -keep class com.google.android.gms.signin.** { *; }
    -keep class com.google.android.gms.dynamic.** { *; }
    -keep class com.google.android.gms.dynamite.** { *; }
    -keep class com.google.android.gms.tasks.** { *; }
    -keep class com.google.android.gms.security.** { *; }
    -keep class com.google.android.gms.base.** { *; }
    -keep class com.google.android.gms.actions.** { *; }
    -keep class com.google.games.bridge.** { *; }
    -keep class com.google.android.gms.common.ConnectionResult { *; }
    -keep class com.google.android.gms.common.GooglePlayServicesUtil { *; }
    -keep class com.google.android.gms.common.api.** { *; }
    -keep class com.google.android.gms.common.data.DataBufferUtils { *; }
    -keep class com.google.android.gms.games.quest.** { *; }
    -keep class com.google.android.gms.nearby.** { *; }

    Links
    https://github.com/playgameservices/play-games-plugin-for-unity/blob/master/scripts/proguard.txt
    https://stackoverflow.com/questions/61013678/google-play-games-service-in-unity-doesnt-authenticate
     
    DankalApps, reHgoc, Starbox and 2 others like this.
  7. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    189
    Before you make it open source you should remove your appID and ClientID and then instruct anyone wanting to use your open source project to use their own appID and ClientID.
     
    SebT_Unity likes this.
  8. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    Hey thanks for the guide, I tried it but when I copy paste the SHA1 from my custom keystore that I use when building my game, I have an error on the SHA1
    upload_2023-4-17_20-54-52.png
    It's really odd because the SHA1 I get from my .keystore seems very long, if I chop it down the sha-1 gets approved but I'm 100% sure the authentication will fail.
    Do you know what causes this and how to fix it ?
    edit: otherwise my debug process is very very long I have to publish the app in an internal track in order to test it :/
     
    Last edited: Apr 17, 2023
  9. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    266
    Hi @rbitard,
    I had a similar error when I was redoing the steps. I tried to circumvent some steps by reusing a keystore.

    Make sure your package name you have on the google dashboard matches the package name you registered when you create your keystore.
     
    rbitard likes this.
  10. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    Oh ! You are probably right since I created it a long time ago ! Thanks I'll try that
     
  11. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    I retried and I have the same error.

    I don't know what I'm missing
    my game is com.unscripted.crapette so I put unscripted in my organization name.

    What should I use to make it work ?
     
  12. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    What is odd is that it's supposed to be the app upload key in google play store and when I go check it out
    my sha1 in google play store is the MD5 when I type the command
    and my sha256 is my sha1
    upload_2023-4-18_10-13-53.png
     
  13. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    I tried to use the MD5 when using keytool (that appears as the SHA1 in google APP-Integrity) and I have a sign in failed as I expected :(
    (whereas when I upload using internal app sharing the sign in works because the sha1 is valid I guess)
     
  14. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    it seems to work with the MD5 from keytool as the SHA1, which is odd, might be a fluke
     
  15. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    189
    Does it work with external testing rather than internal testing?
     
  16. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    it's external testing by default I can't select internal testing
     
    Julian-Unity3D likes this.
  17. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    189
    Well I'm glad you now have it working, I'm not too sure why it worked out that way for you, but at least its working
     
    rbitard likes this.
  18. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    SebT_Unity and Julian-Unity3D like this.
  19. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    266
    Thanks for pointing that out rbitard and sharing that link. I will append it to the document as a requirement!
    Minify helps decrease the size of your project. You should be fine without it unless you are really trying to minimize your application size by minimizing the code calls and classes. It detects any code or libraries that aren't being used and ignores them (in this case it seems those ignored libraries are causing problems)
     
    rbitard and Julian-Unity3D like this.
  20. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    I don't know if it's me but I can load the leaderboardUI but I can't post a score or load scores using Social.Active or PlaygamesPlatform.Instance
    Code (CSharp):
    1. 2023/04/22 13:39:38.412 32247 32291 Error Unity at _Scripts._4FrameworksAndDrivers.GameStateController+<>c.b__19_6 (GooglePlayGames.BasicApi.LeaderboardScoreData data) [0x00000] in <00000000000000000000000000000000>:0
    I'm at the point of using the unity leaderboard beta and developing the UI myself :(
    (which seems like a nice service too)
     
  21. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    I made it work finally but there is a design problem for sure. When the user has no scores it crashes so you have to handle that (post a 0 score or something)
     
  22. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    It stopped working for no reasons, the score doesn't update, when I load scores it takes the previous score (for example I'm at 4 points and it returns 3 o_O) If I had to do it again, I'd implement my own
     
  23. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    189
    Could you open a new thread detailing any issues with Leaderboards on GPG so that we don't spam a thread unrelated to this thread, thanks.
     
  24. rbitard

    rbitard

    Joined:
    Jan 11, 2022
    Posts:
    189
    Sorry about that I just understood it was about authent and not GPGS, I won't bother you :). I won't create a thread since I'll do my own (minimalistic) version of the leaderboard, it's not worth it imo to use GPGS for that
     
  25. Netherzapdoss

    Netherzapdoss

    Joined:
    Dec 30, 2022
    Posts:
    3
    Is there absolutely no way for me to enable google authentication for a windows build?
     
  26. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    189
    Unfortunately we do not have a google authentication for windows build support, but I believe it is being worked on. We are working on a google Sign-in with Authentication tutorial which will be shared here and on a pinned post on the forum, if windows is supported it'll likely be included in that tutorial but I can't promise anything just yet.
     
    Netherzapdoss likes this.
  27. douglas_unity105

    douglas_unity105

    Joined:
    May 17, 2021
    Posts:
    3
    I got a 403 Not Authorized error on the Authentication step. I have re-done it twice (including removing the credentials and keystore and recreated a new one) from the beginning and it still doesn't work. Am I missing something?
     
  28. douglas_unity105

    douglas_unity105

    Joined:
    May 17, 2021
    Posts:
    3
    Turns out I can do the Authentication step from Unity Dashboard and it worked. Probably a bug from the unity package plugin that blocked me from proceeding
     
    SebT_Unity likes this.
  29. douglas_unity105

    douglas_unity105

    Joined:
    May 17, 2021
    Posts:
    3
    Sorry again. I have encountered another issues with authenticating. I am using the GPManager class and the authentication results failure. Here is the log attached. What am I missing here? I have added myself as a tester on play console but nothing seems to change. Thank you in advance!
    upload_2023-5-17_15-42-26.png
     

    Attached Files:

  30. sampenguin

    sampenguin

    Joined:
    Feb 1, 2011
    Posts:
    51
    I just spent several days fighting this exact problem I was seeing in my logs. In my case, I had to add a second Android credential in the Google Play Console.
    1. There is one that corresponds with the SHA Fingerprint for any APKs I build and test on my local hardware using my local keystore.
    2. There is a second *different* credential that corresponds with the SHA Fingerprint that Google uses when it re-signs your uploaded apks/aabs in the console.
    You can check if you're using Google's app signing in the Google Play Console->Release->App integrity and select the App signing tab. The "App signing key certificate" is the one used to distribute your build on Google Play. The "Upload key certificate" is the one you use locally for your dev builds, i.e. what the apks/aabs you upload to the console are originally signed with (which is then stripped and the Google one is applied instead before distributing it).

    So that got me past the
    ERROR: Returning an error code
    message, and I was able to see the little visual sliding overlay in my app confirming the GP user was authenticated. However, I immediately got a different error in my logs, so on to the next mystery...

    TL;DR: If you're using Google's app signing feature (which everyone is these days), and want to see GPGS work on local dev devices as well as testing devices and production devices, you need TWO Android credentials AND the Game server credential.

    It would be really great if the tutorial was updated with this critical info.

    (Side Note: This is my 5th or 6th game using GPGS... EVERY single time it's a massive PITA to get this working. Don't understand how it keeps getting more complicated every time I push a new title out >< )

    Also if anyone from Google/Unity SDK collab is paying attention to this, it would be just super duper helpful to return an error a little more informative than:

    Code (CSharp):
    1. namespace GooglePlayGames.BasicApi
    2. {
    3.     public enum SignInStatus
    4.     {
    5.         /// <summary>The operation was successful.</summary>
    6.         Success,
    7.  
    8.         /// <summary>An internal error occurred.</summary>
    9.         InternalError,
    10.  
    11.         /// <summary>The sign in was canceled.</summary>
    12.         Canceled,
    13.     }
    14. }
    Like, if I would have known the reason for the auth failure was a mismatched fingerprint in the Android credential, I wouldn't have burned 5 working days just stabbing in the dark until something worked.
     
    Last edited: May 17, 2023
    Gonios, SrNull, ihgyug and 3 others like this.
  31. malikaran740

    malikaran740

    Joined:
    Oct 2, 2020
    Posts:
    7
    Error :
    Exception: Failed
    GPManager.Start () (at Assets/Scriptes/GPManager.cs:23)
    upload_2023-5-29_21-2-16.png
     
    Butterapps likes this.
  32. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    428
    With the most simple and mundane use of the Google Play Services... wait, Google Play GAMES, to get access to the app's leaderboards, do we still need the v11.01 and need to:
    1. install the Unity Authentication package?
    2. create BOTH an Android OAuth AND a Game Server credential?
    3. use the "client secret" too?
    Do we need a new OAuth for both of them if for example we have changed the app's keys (which is the uploading key, not the one created by Google once they receive the APK/AAB)?

    Is the Game Server credential related to what appeared in some documents as a Web Application authentication?

    Also, once an Android credential is created, it doesn't seem possible to display the options as seen below:

     
    DankalApps likes this.
  33. JVimes

    JVimes

    Joined:
    Jan 3, 2022
    Posts:
    6
    Thank you @SebT_Unity! I see drive.app data not under Google Play Game Services. Screen shot issue?
    upload_2023-6-8_12-46-44.png
     
  34. reHgoc

    reHgoc

    Joined:
    Jul 25, 2018
    Posts:
    2

    Great, thats work.

    One more advice - checking your file Manifest in project.
    Check string package - there should be your package name (me helpful it)
     
  35. SplenShepard

    SplenShepard

    Joined:
    Aug 24, 2019
    Posts:
    16
    How can we turn off the automatic user authentication? For example, i ONLY want the Play Games sign in to show when I call PlayGamesPlatform.Instance.ManuallyAuthenticate.

    I DO NOT want the automatic authentication to bring up a dialog for the user when the app starts. This causes friction. I'm trying to use the Unity anonymous login according to your own best practices, and I can't do that when PlayGamesPlatform brings up the sign in dialog on app start.

    EDIT: Looking through the code, it's possible it doesn't bring it up until the first call of PlayGamesPlatform.Instance, since that's when the SDK is initialized. Doing some testing.
     
    Last edited: Jun 15, 2023
  36. DankalApps

    DankalApps

    Joined:
    Mar 8, 2023
    Posts:
    17
    Could someone please clean and update the instruction?
    1. Some things does not appear when I follow instruction (e.g. as @Starbox showed above, I see no dialog with scopes to choose from)
    2. I have no understanding what is being done and why. For example, there is instruction to create Android OAuth client, then, without any information, there is instruction to create Web app OAuth client. Why we need two of them (do we??), which one is for what.
    3. I literally stumbled upon this page after trying old instructions, so probably I have some things not set correctly at some of the stages. And I have no idea how to check them and fix them.

    I was lost before I got here and am still very confused. From the very start I get the same "Canceled" SignInStatus and not a single clue what is causing this.


    EDIT: how to find and edit scopes for already created credentials:
    1) go to OAuth consent screen webpage: https://console.cloud.google.com/apis/credentials/consent
    2) click EDIT APP
    3) click SAVE AND CONTINUE
    4) click ADD OR REMOVE SCOPES
     
    Last edited: Jun 19, 2023
  37. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    428
    FWIW, from my modest perspective, I had a build version where the Game Services were not initialized on startup but would only be triggered if the player went into anything that would require this API, like for example in a "records" section to look at scores or else. Nevertheless, even with this method, there would be that top banner popup that would appear soon into the launching of the app, the one saying something like "welcome back", and showing one's avatar.

    What kind of friction does it create? Are you principally annoyed by the entire rectangular pop up showing up in the middle of the screen, putting your app on hold for a brief moment, before disappearing and letting your app continue its launching process?
     
  38. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    428
    It's probably easier to just create two new IDs, a 'client android' and a 'client web', and directly from the Google Cloud's console (there's a link if you go in App > Play Game Services > Setting and Management > Settings). The link will be named something like "Display on Google Cloud Platform".
    In the Play Console you can refresh the OAuth clients. Be sure that the web one (that's going to be used for the server) is not in draft. You will have to publish it.
    Also, check in the Cloud Platform be sure to look for all the options about testing, who's been added (email adresses), if it's in testing or published mode, internal or external, etc.
     
  39. DankalApps

    DankalApps

    Joined:
    Mar 8, 2023
    Posts:
    17
    Thank you. In my case problem was I followed blindly tutorial and generated... second SHA1 certificate. I already had one generated and signed app with it during my previous attempts, before I even got here.
     
  40. mohamedtaher_idriss

    mohamedtaher_idriss

    Joined:
    May 28, 2019
    Posts:
    1
    Hey did you manage to solve this?
     
  41. malikaran740

    malikaran740

    Joined:
    Oct 2, 2020
    Posts:
    7
    @mohamedtaher
    Go to Play Console > Testers and add email id for testers. Use the email id logged in in your phone GPGS and build and run in your phone.
    Please make sure email id also added in testers in google cloud android setup
     
  42. frozenwolfstudio9

    frozenwolfstudio9

    Joined:
    Jun 7, 2023
    Posts:
    5
    Hello! I have the following issue when testing on my mobile.

    It seems that that I can authenticate, I'm getting an authorization code, but when calling SignInWithGooglePlayGames, it seems that it fails at await AuthenticationService.Instance.SignInWithGooglePlayGamesAsync(authCode). Anybody encountered this issue?

    upload_2023-7-15_23-37-23.png
     
    Ohilo likes this.
  43. Nextoor

    Nextoor

    Joined:
    Jun 27, 2020
    Posts:
    1
    I've made this tutorial from scratch twice, and the result is the same. I can get the game working with Google Play Services (login and leaderboard) when testing in Unity to my phone, but not when I upload the aab to google play for internal testing. It fails to retrieve Google Play Games authoritazion code.
    How can I accomplish what sampenguin wrote?
    1. There is one that corresponds with the SHA Fingerprint for any APKs I build and test on my local hardware using my local keystore.
    2. There is a second *different* credential that corresponds with the SHA Fingerprint that Google uses when it re-signs your uploaded apks/aabs in the console.
    I'm trying to make it but I cannot figure it out. Could anyone point me in the right direction? This is my first game, so I'm very confused with this. Thanks guys.
     
  44. Smeaglr

    Smeaglr

    Joined:
    Mar 8, 2019
    Posts:
    1
    This is great and works (it signs me in); however, it causes the scene/unity player to freeze when run on a device.

    The pre-loader, very basic just determines whether the tutorial should load or the main menu, remains a black screen, or any of my other scenes will show some of the graphics and play music but no UI or parallax effects I have, my scenes load halfway through and gets stuck when it signs in the tester account that is linked to the oauth consent api.

    Devices: android studio AVD, Pixel 3, Nox Emulator. Logcat has no helpful info either when connected to them.
     
  45. hiddentldr

    hiddentldr

    Joined:
    Jul 17, 2018
    Posts:
    6
    I've been trying to make this work for days, I've followed the guide multiple times exactly and tried everything I could find in this thread, but I always get "SignInStatus.Canceled" when calling PlayGamesPlatform.Instance.Authenticate (I'm using the provided code).

    Any idea what could be going on? This is making me abandon google play services. Using an email/password login will be more uncomfortable for users but I have no other choice for cloud save.

    This is ALL I get from logcat, as you can see there is no usable errors or logs at all:


    2023/08/02 00:46:06.947 5233 19823 Warn Unity *** [Play Games Plugin 0.11.01] 08/02/23 0:46:06 +02:00 ERROR: Returning an error code.
    2023/08/02 00:46:06.947 5233 19823 Warn Unity GooglePlayGames.OurUtils.PlayGamesHelperObject:Update()
    2023/08/02 00:46:06.947 5233 19823 Warn Unity
    2023/08/02 00:46:06.948 5233 19823 Error FileUtils err open mi_exception_log errno=2
    2023/08/02 00:46:06.948 5233 19823 Error FileUtils err write to mi_exception_log
    2023/08/02 00:46:06.949 5233 19823 Info Unity RESULT: Canceled
    2023/08/02 00:46:06.949 5233 19823 Info Unity <>c__DisplayClass4_0:<LoginGooglePlayGames>b__0(SignInStatus)
    2023/08/02 00:46:06.949 5233 19823 Info Unity GooglePlayGames.OurUtils.PlayGamesHelperObject:Update()
    2023/08/02 00:46:06.949 5233 19823 Info Unity
    2023/08/02 00:46:06.949 5233 19823 Info Unity Login Unsuccessful
    2023/08/02 00:46:06.949 5233 19823 Info Unity <>c__DisplayClass4_0:<LoginGooglePlayGames>b__0(SignInStatus)
    2023/08/02 00:46:06.949 5233 19823 Info Unity GooglePlayGames.OurUtils.PlayGamesHelperObject:Update()
    2023/08/02 00:46:06.949 5233 19823 Info Unity
    2023/08/02 00:46:06.955 5233 19823 Error Unity Exception: Failed
    2023/08/02 00:46:06.955 5233 19823 Error Unity at GPManager.Start () [0x00000] in <00000000000000000000000000000000>:0
    2023/08/02 00:46:06.955 5233 19823 Error Unity at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
    2023/08/02 00:46:06.955 5233 19823 Error Unity at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0
    2023/08/02 00:46:06.955 5233 19823 Error Unity at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0
    2023/08/02 00:46:06.955 5233 19823 Error Unity at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0
    2023/08/02 00:46:06.955 5233 19823 Error Unity at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0
    2023/08/02 00:46:06.955 5233 19823 Error Unity at System.Threading.Tasks.Task.TrySetException (System.Object exceptionObject) [0x00000

     
    Last edited: Aug 4, 2023
  46. reHgoc

    reHgoc

    Joined:
    Jul 25, 2018
    Posts:
    2
    Ok, me a collide with it troubles -
    first your look in google play games console application signature in integrity API settings (copy SHA key from here to console in OAuth - then got a new clientID and client secret)
    It hard to understanding, google want to protect your app and generating own SHA for app (SHA which you use - it's upload key)
    Also check in google cloud console - Oauth consent screen.
    You should connect all play games services like as it this tutorial
     
  47. hiddentldr

    hiddentldr

    Joined:
    Jul 17, 2018
    Posts:
    6
    Thanks, but not sure I understand?
    As I've said, I've followed the guide multiple times exactly
     
  48. doublehitgames

    doublehitgames

    Joined:
    Mar 5, 2016
    Posts:
    90
    Hey im have the same problem here. But im testing my APP directly from local unity build at my Phone, with a USB cable coonected, and im manager the logs at realtime at Unity Editor. At you problem you was with problem at your public BUILD right?

    So why im with the same problem at my local build test?
    Kinda, my main doubt now is: Can i test it without publicate a build at console?

    For knowedge i found the certicates that you saw at your post.

    upload_2023-8-26_12-29-20.png

    Is this where the solution is? I don't understand how you solved this.

    My Log is equal of you:
    upload_2023-8-26_12-31-11.png

    Anyone could gimme some HELP? Im trying it for a lot of days.. I Will crazy!
     
  49. doublehitgames

    doublehitgames

    Joined:
    Mar 5, 2016
    Posts:
    90
    Ooow I Miss my informations for some help.
    I already the thow credentials from cloud console:
    upload_2023-8-26_12-36-10.png

    At google Play console i have too:
    upload_2023-8-26_12-38-25.png

    I Configured all equal the tutorial! I Generate correcly my SHA1, and i configured correctly the UnityEditor GooglePlay Games Pack and Unity Authentication pack witch WebClient ID and Client Secret generated by Game Server Certificate.

    So, i cant understand.. Why?????


    I'm looking in other forums and I even used BARD and ChatGPT kkk. Unfortunately I can't understand.

    I have noticed that this error always occurs when people publish their games publicly. When the game is published, they forget or don't know that there is another certificate for it. They continue using the test version certificate and therefore cannot authenticate and the log that appears for them is the same as mine.

    But I don't have my APP Published.
    To make sure the problem is real here, I even published an Internal Test version of the game. I downloaded this version on my device and listened to the LOGS.. Same issue occurs. Both building directly from unity on my cell phone and testing the version for internal web tests.

    I don't know what else I should do. I redid the tutorial many times and made another project to test and in both, the problem is the same!
     
  50. a2zescapegames

    a2zescapegames

    Joined:
    Mar 27, 2023
    Posts:
    4
    Use App signin SHA1 certificate(Unity Dashboard)