Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Question Google Play Authentication

Discussion in 'Authentication' started by targaciej, Apr 12, 2022.

  1. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    I can't give a solid date, however I have tested the new support document and can successfully say it works as intended now.

    I was over the moon when I got it working in my project and I'm sure you all will be happy too.

    However, we are doing one last internal test to confirm it. So as long as it goes through smoothly then it will likely be the end of Friday, or next week at the latest.
     
    dmax9, TheKingNuro and SF_FrankvHoof like this.
  2. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
  3. TheKingNuro

    TheKingNuro

    Joined:
    Nov 13, 2021
    Posts:
    5
    Thanks! Apperantly I was doing it like mostly correct just Sha-1 key was wrong. Also it was super helpful to see which client id's go where. Thank you very much.
     
  4. carored

    carored

    Joined:
    Mar 21, 2018
    Posts:
    11
    Is there a solution for webgl login? Facebook sdk package works fine for this. Why there is not a similar package for google.
    If my game is webgl I don't need to create an app in Google Play. I just want to sign in with Google.
     
  5. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    @carored, if you'd like to login with just google instead of google play games, can you start a new thread, you can even tag me in it. That way we can keep the two separate. Thanks.
     
  6. carored

    carored

    Joined:
    Mar 21, 2018
    Posts:
    11
    Thank you Julian a made the new thread, I don't know how to tag you. here is the link https://forum.unity.com/threads/google-sign-in.1412070/
     
    Julian-Unity3D likes this.
  7. AusAdam

    AusAdam

    Joined:
    Jan 2, 2021
    Posts:
    62
    This is great and helped people get the Auth code but Most of us could already get that before...The problem is with the backend. How do you use the Auth Code in php to get the players google play id??
     
  8. vuqarahim

    vuqarahim

    Joined:
    Dec 4, 2020
    Posts:
    4
    is there still no way of signing out / switching accounts? what if a player automatically signs in with one account and wants to switch it?
     
  9. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    Google don't currently offer a sign out feature for Google play games within a game, however you could try signing out of the google play app and see if you can switch accounts that way?

    Just make sure your Authentication logic is set up correctly so that you pull the correct data for each player.
     
  10. malikaran740

    malikaran740

    Joined:
    Oct 2, 2020
    Posts:
    11
    Still not working for me
     
  11. frozenwolfstudio9

    frozenwolfstudio9

    Joined:
    Jun 7, 2023
    Posts:
    15
    any news on this matter ?
     
  12. cyberover

    cyberover

    Joined:
    Dec 10, 2021
    Posts:
    1
    I did google play and google auth with this
     
    sandolkakos likes this.
  13. Wilson9253

    Wilson9253

    Joined:
    Sep 9, 2022
    Posts:
    3
    Hello, I'm having an issue with PlayGamesPlatform.Instance.Authenticate((success) => from the LoginGooglePlayGames() method
    The line above returns me Canceled from the success variable.
    Any update on that?
     
  14. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    471
    I concur that the whole setup is now a very complicated structure. For a contextual purpose, let it be known that I do have created both an Android and a Web app clients.
    The APK uses the following SDKs and tools:
    • GPS 0.11.01
    • Unity Authentication 2.6.1
    I'm bumping this because I'm testing an APK on a different and newer device with a different account, and I found out that the Google Play Services plugin will just no launch, connect or do anything from the device. Pressing a button that is meant to open the leaderboards does nothing either.
    The new device I'm using this on is;
    • not declared as a testing device anywhere (Unity/Google)
    • the account is not declared as a tester account (Unity/Google)
    As a matter of fact it throws a rather non-descript and absolutely unhelpful warning message in the log that looks like this:

    But the error code isn't even provided.
    The GPS plugin works on the older test device I used thus far, which is a known testing device and on which my main testing account is declared. That, whether I build & run or simply copy & paste the APK and install it directly from the device (by using a file explorer app), it does work flawlessly.

    I wouldn't be able to install that APK from the Google Play servers (using for example a special download link from the Internal release track from the Google Play Console) onto the new device because neither it or the secondary account I use on it are declared on the Google Play console (or in Unity as a matter of fact). IOW I could only expect the plugin to work on this device if it received a public release of the game (under the form of an AAB file btw, not an APK).

    As per implied in the question I cited, it may seem logical that not declaring a device and/or a tester account will somehow block any attempt at connecting to the GPS servers... if only it were consistent with other how other plugins work, because all other systems, including the payments (Unity IAP reaching the Google Play servers for purchases), do work without any issue.
    GPS seems to be one of the few, if not the only one system to be throwing road blocks during the Q&A process and preventing random Android devices from enjoying a functional GPS plugin by manually installing an APK outside of the Google Play environment.

    An equally terrible offender is how historically, the Google Play plugin went from being an asset to a package and back to being an asset, with all the funny compatibility and duplicates issues this caused.
     
  15. sb33

    sb33

    Joined:
    Sep 9, 2021
    Posts:
    3
    Hello,

    My team and I are trying to implement Google Sign-in for a Unity mobile app running on Android and IOS. All of the documentation that we found is relevant to Google Play services rather than a standard Google account. Is there any way to just authenticate using google sign in?

    any reply would help, Thanks!
     
  16. doublehitgames

    doublehitgames

    Joined:
    Mar 5, 2016
    Posts:
    97
    Hey guys, could anyone gimme some help with this?
    Im trying to use Unity Identity provider with Google Play games auth, but its not working for me, and i have no detalhed log of the why!

    Im following the Google Play tutorial from forum. I already done all steps detalhedy.
    Im try to test with Unity Editor and my phone at USB Depuration. When i test, im getting this warning Message:

    Screenshot 2023-08-26 121308.png
    And my login fail!
    Please, anyone could helpme to understand what happening here?

    I noticed in other topics that this same message is shown for users who are using different certificates in production. For example: Using a test certificate in production. But in my case, I don't have my game published to the public. I'm just trying a local test with calular on the cable. I also tested with an INTERNAL version published on the GooglePlay console, but the same problem occurs!
     
  17. doublehitgames

    doublehitgames

    Joined:
    Mar 5, 2016
    Posts:
    97
    OK. Solved. I Just Generated a new Secret and configurated the Editor Autentication with this new secret. So its working now. UHUUU!
     
  18. Ohilo

    Ohilo

    Joined:
    Jul 30, 2021
    Posts:
    32
    @Julian-Unity3D It appears Google had made a change on March 31st due to which the Official tutorial doesn't work with Play Games Services plugin v11.01. I am able to sign in to Play Game Services but the method SignInWithGooglePlayGamesAsync leads to the error as seen in the screenshot. I am desperately seeking a solution.
     

    Attached Files:

  19. Ohilo

    Ohilo

    Joined:
    Jul 30, 2021
    Posts:
    32
    Has there been any update on this?
     
  20. Ohilo

    Ohilo

    Joined:
    Jul 30, 2021
    Posts:
    32
    @Julian-Unity3D I am as commented multiple times but haven't received any response from the Unity team.
     
  21. YinZuoyu

    YinZuoyu

    Joined:
    Aug 25, 2015
    Posts:
    44
    Hi,
    I had the same problem.
    Does the secret you mentioned refer to a client secret?
    I've tried it, but it didn't work.
     

    Attached Files:

  22. doublehitgames

    doublehitgames

    Joined:
    Mar 5, 2016
    Posts:
    97
    upload_2023-10-16_14-5-2.png

    When you access the Settings from Play APP Signing, you will see these certificates:

    App signing key certificate
    Upload key certificate

    The certificate from Upload key, is a certificate just for debug test, you can use it only at Build with (Cable connected and Unity Editor).

    The Signing key is the key for the app downloaded from googlePlay.
    So in my case, my SHA1 configured at my Android Credential was using the upload key and not the app sgnining key.

    You can change it from Google Cloud API & Services.
    You can access it from Play Game Sevices -> Configurations -> Android certificate
    upload_2023-10-16_14-12-2.png

    At GoogleCloud -> Credentials, just change the upload key in SHA-1 Certificate to APP SIGNING KEY

    upload_2023-10-16_14-15-5.png

    With this, my tests using download app directly from googlePlay work!
     
    again likes this.
  23. vuthang

    vuthang

    Joined:
    Mar 7, 2017
    Posts:
    50
    I get this error when I try re-login after logout: Unity.Services.Authentication.AuthenticationException: unable to validate token ---> Unity.Services.Authentication.WebRequestException: {"title":"PERMISSION_DENIED","detail":"unable to validate token","details":[],"status":401}
     
  24. vuthang

    vuthang

    Joined:
    Mar 7, 2017
    Posts:
    50
    I use PlayGamesPlatform.Instance.ManuallyAuthenticate instead of PlayGamesPlatform.Instance.Authenticate. Now I can logout and re-login success every time
     
  25. jesselugassy_unity

    jesselugassy_unity

    Joined:
    Jul 2, 2018
    Posts:
    4
    hi guys i to downgrade to the suggested v0.10.14

    this code returns the authcode with that version

    Code (CSharp):
    1.                 PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestIdToken().RequestServerAuthCode(false).Build();
    2.                 PlayGamesPlatform.InitializeInstance(config);
    3.                 PlayGamesPlatform.Activate();
    4.                 PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptOnce, (result) =>
    5.                 {
    6.                     // handle results
    7.                     if (result == SignInStatus.Success)
    8.                     {
    9.  
    10.                         loginString = PlayGamesPlatform.Instance.GetServerAuthCode();
    11.                     }
    12.                 }
    and then on my server


    Code (CSharp):
    1.                     string authCode = message.GetString();
    2.                     //Console.WriteLine("AUTHCODE: "+ authCode + "\n");
    3.                     var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"client_secret.json");
    4.                     var config = File.ReadAllText(path, Encoding.UTF8);
    5.  
    6.                     GoogleClientSecrets clientSecrets = GoogleClientSecrets.Load(new FileStream(path, FileMode.Open));
    7.  
    8.                     WebClient webClient = new WebClient();
    9.                     NameValueCollection postData = new NameValueCollection();
    10.                     postData.Add("clientId", clientSecrets.Secrets.ClientId);
    11.                     postData.Add("clientSecret", clientSecrets.Secrets.ClientSecret);
    12.                     postData.Add("redirectUri", "");
    13.                     postData.Add("code", authCode);
    14.                     postData.Add("grantType", "authorization_code");
    15.                     byte[] responseArray = webClient.UploadValues("https://www.googleapis.com/oauth2/v4/token", "POST", postData);
    16.                     string response = System.Text.Encoding.UTF8.GetString(responseArray);
    17.                     Console.WriteLine(response);
    the response will now include my idtoken

    ty for all the help humans and huwomens
     
  26. Hackdamm

    Hackdamm

    Joined:
    May 4, 2019
    Posts:
    2
    Is this issue finally solved? 3 years and i still cant get a token back from google
     
  27. jesselugassy_unity

    jesselugassy_unity

    Joined:
    Jul 2, 2018
    Posts:
    4
    hi i ran into another problem again yesterday which i was able to solve. for "PlayGamesPlatform.Instance.GetAnotherServerAuthCode(true, (result)" to return the idtoken as well you need to add "AddOauthScope("openid")" to the config. "PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestIdToken().RequestServerAuthCode(false).AddOauthScope("openid").Build();"
     
  28. cshombith

    cshombith

    Joined:
    Jul 20, 2022
    Posts:
    1
    Any updates? I am stuck at the same issue. How is everyone doing the gpgs login? Downgrading the project?
     
  29. malikaran740

    malikaran740

    Joined:
    Oct 2, 2020
    Posts:
    11
    The Unity Authenticator is not working for gpgs testing purpose. How do i use it?
     
  30. Vivoxbl

    Vivoxbl

    Joined:
    Apr 15, 2024
    Posts:
    1
    I had a similar issue before. Make sure you've set up the OAuth 2.0 client IDs correctly in the Google Play Console and that your app is properly configured to use them. Double-check the scopes and permissions as well. If you're still having trouble, maybe try reaching out to the plugin's support or community forums for more specific guidance.
    Speaking of authentication problems, I'm looking for an ID scanner/checker system for work. My friend advised me to check out this fake id checker system that he uses. I will try it, but if you have any other tips, please let me know. Thanks!
     
    Last edited: Apr 17, 2024