playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.43k stars 954 forks source link

Authentication Not Working #3091

Closed ShenaniganzStudio closed 2 years ago

ShenaniganzStudio commented 2 years ago

Please help :(

I've been at this for 4 days now with no luck. I've combed through just about every tutorial I can find, every piece of documentation located here/online forums/google consoles/ etc., and tried working the Minimal sample project as well. It still always fails to authenticate.

I've quadruple checked my Oauth certificates, package names, android manifests, resources, tester emails, etc. and everything SEEMS to be correct, but it obviously isn't.

I'm using Unity 2019.4.10f1 (LTS).

if someone would be willing to go through it all quick with me and see what I'm missing, that would be amazing. We can setup a discord session or something. I'm getting desperate lol

Di3master commented 2 years ago

i have exactly same problem... i'm using 2019.4.30f1. i checked everycase on my project and also tried all way on cloud platform. 10 days ago everything was okay.

ShenaniganzStudio commented 2 years ago

I upgraded my project to the newest 2020 LTS version, and now I get the prompts to pop up and can accept the permissions I've requested in Google Cloud. Then it fails to sign in.

On Mon, Nov 22, 2021, 12:58 PM Di3master @.***> wrote:

i have exactly same problem... i'm using 2019.4.30f1. i checked everycase on my project and also tried all way on cloud platform. 10 days ago everything was okay.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/playgameservices/play-games-plugin-for-unity/issues/3091#issuecomment-975779834, or unsubscribe https://github.com/notifications/unsubscribe-auth/AS364DEWQSMZ63R2CC7SJVLUNKAENANCNFSM5IPN4ANA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Di3master commented 2 years ago

I'm already getting the prompts on 2019 but it gives "error code 10" after permission.

Error SignInRequest Sign-in failed with status code: 10 Error SignInRequest Setting result error status code to: 10

ShenaniganzStudio commented 2 years ago

I've finally got it working and can sign in successfully, but to be honest I don't know what I did that changed it. I just started throwing everything at the wall to see what would stick lol

I believe your error code is a DEVELOPER_ERROR. My understanding is that it is probably due to incorrect Oauth credential configuration. Make sure you have client IDs created in the cloud console for all SHA-1 keys and make sure they are all linked in Play Console > Play Games Services > Configuration. I created one each for the dev key (debug), the app signing key that google generates, and the upload key. You can get those under Play Console > Setup > App Integrity. I threw one in there for a web client ID as well just to cover everything.

Di3master commented 2 years ago

I had installed the 10.13 version, but when I reinstalled the 10.12 and problems fixed. Now there's another problem. After authenticating a few times with the test email I added, it doesn't allow me to auth it again.

bogmix commented 2 years ago

Plugin V10.13 does not work:

SignInRequest Sign-in failed with status code: 10 SignInRequest Setting result error status code to: 10

shefich commented 2 years ago

Same for me. Only for the new version 10.13. Downgraded to v0.10.12 and sign-in works.

ozdemir08 commented 2 years ago

I will look into that early next week. If you are not using Unity 2021.2, then continue using v10.12. If you are using Unity 2021.2, then use v10.12 with the manual fix recommended here.

ozdemir08 commented 2 years ago

One question that would be helpful to me is after building the apk, could you go to Android Studio > Build > Analyze APK and check if AndroidManifest.xml includes a field for APP_ID and let me know what Unity version you are using?

ozdemir08 commented 2 years ago

Hi everyone. I prepared a fix that you can find here but haven't released it in the public repository yet. Could you test it and let me know if it works for you and what Unity version you tested it on?

moustakakisCon commented 2 years ago

using the latest 10.14 build the error persists. I'm using unity 2020.3.16f1 .

What's interesting is that on all the affected versions, the auth fails only on the first try (with error code "developer error"). If then I call again authenticate, then it will succeed.

ozdemir08 commented 2 years ago

Could you try two things?

  1. Capturing a bug report and sharing it with me?
  2. Checking AndroidManifest.xml in the apk and verifying that the app id field is as expected.
ozdemir08 commented 2 years ago

using the latest 10.14 build the error persists. I'm using unity 2020.3.16f1 .

What's interesting is that on all the affected versions, the auth fails only on the first try (with error code "developer error"). If then I call again authenticate, then it will succeed.

What is interesting to me is if a developer error happens, then you should not be able to sign in at all with the same build. From what you describe, my feeling is that the build actually works well, but just in the first attempt the cached value of your parsed manifest from the previous run persists and it causes and issue on first attempts. Once your manifest is refetched, then it starts succeeding.

Obviously we need to verify it. Answering questions in my previous comment would help.

Also some context on the issue: Your project credentials, mainly the app id, gets put into an AndroidManifest file in GooglePlayGamesPluginManifest and when building the project for Android, Unity detects this folder as an Android library and merges it into the main manifest file. When this directory is not detected as an Android Library, then the app id field misses from your apk's manifest file, leading to an unresolvable developer error.

Unity changed the way it identifies Android libraries in a project from version 2020 on. See the difference in 2020 and 2019. And the problem to solve here is how to get GooglePlayGamesManifest to be detected by all versions.

moustakakisCon commented 2 years ago
  1. Bug report
  2. I have verified that the app id is included in the final apk build.

if it is any further help, the steps i follow to reproduce it are:

  1. After succesfully logging in (by the workaround i said of calling the authenticate twice), I clear the app's data
  2. in the Google Play Games app, in the settings -> Delete Play Games Data tab, i delete the game.
  3. Redoing the log in flow will result in error 10
ozdemir08 commented 2 years ago
  1. Bug report
  2. I have verified that the app id is included in the final apk build.

if it is any further help, the steps i follow to reproduce it are:

  1. After succesfully logging in (by the workaround i said of calling the authenticate twice), I clear the app's data
  2. in the Google Play Games app, in the settings -> Delete Play Games Data tab, i delete the game.
  3. Redoing the log in flow will result in error 10

@moustakakisCon thanks a lot for the bug report and clarifying the reproduction steps. They were very helpful. Everything actually looks to be working fine. Let me explain how:

  1. The issue that many people reported above was caused by the app id field not being in the manifest file. It was about the way Unity detects an android library differently in different versions. This problem consistently led sign-in attempts to fail.

The fix with the v10.14 (shared above) aims to fix this problem for all Unity versions. As you verified it on Unity 2020.3.16f1, the app id is in the manifest, so the fix is working as expected for this version. However, I would be happy if someone verified it on Unity 2019 as well.

  1. After a successful authorization, a token gets cached and also reused for further interaction. When you delete the game data, the token gets invalidated on the server side. But in the next sign-in attempt as there is already a token on the client side (even though invalidated), you get an error. Next time when you go through the sign-in flow, it gets a new token and following sign-in attempts succeed. As deleting a game's data and coming back to the same game to sign in is a very rare use case, it is intentionally accepted for that sign-in attempt to fail.

I would agree however that perhaps a better error code could be thrown here and I will take a look into that.

To sum up, you can go ahead with this version of plugin and safely use it. Calling authenticate only once will be enough.

shefich commented 2 years ago

Unity 2019.4.19f1, still developer erro code 10. Don't have APP_ID in the final Manifest file. BTW why you can't test internally berfore releasing the final version? You can install Unity Hub and test on every wanted version of Unity.

ozdemir08 commented 2 years ago

Unity 2019.4.19f1, still developer erro code 10. Don't have APP_ID in the final Manifest file. BTW why you can't test internally berfore releasing the final version? You can install Unity Hub and test on every wanted version of Unity.

I first tested it internally actually. I was able to see the APP_ID in the final manifest file. After your comment, I checked it again and it looks working in my environment.

Could you

  1. Go to Window > Google Play Games > Setup... > Android Setup and click Setup.
  2. Verify the app id field in Assets > Plugins > Android > GooglePlayGamesManifest.androidlib exists and has the right value.
  3. Then build the project and check whether the apk's manifest file has the app_id field.
shefich commented 2 years ago

Yes, I checked that app id field has the right value. I am checking this after each update of the SDK. And I checked it after the current update and before build. Also I searched in the manifest the actual numerical value alongside just "app_id". It also doesn't exist.

shefich commented 2 years ago

As I mentioned before, if I downgrade to the previous version, everything works fine.

ozdemir08 commented 2 years ago

Thanks for checking that. As I can't reproduce the issue, it will be a bit tricky to do further investigation now. If someone else could check it and let me know the outcome, that would be great.

ozdemir08 commented 2 years ago

I tried it with Unity 2019.3.11f1 and it works for me. I will go ahead and make a release and see if more developers are still having the same issue. The devs using 2019 and still having the same issue can use v10.12.

I will come back in a few weeks and check what the case is and continue with further investigation using new findings, if necessary.

XanderQue commented 2 years ago

To start off I literally started on this project in the last couple of weeks with 0 exp. with google play services, I just released my first game in Nov 2021. Previous to finding this thread I read someone's comment that there was a bug, in GPGS plugin v10.x from a YouTube video on "how to setup GPGS on Unity" after a 2 weeks of no success authenticating. So I installed plugin 9.64 before realizing there were newer versions. This actually worked and I was able to log in plenty of times, until I used the SmokeTest sample, it was here that I signed in one last time and never Authenticated again.

Then I found this thread and here is where I am at. Currently I am using Unity 2021.2.5 but started from 2019.4.32f1, I used the minimal(10.14 & 10.12) sample to test play services. I kept running into authentication failed issues and re-setup my app on the Google Cloud Platform and Play Console multiple times. I am currently using my debug SHA-1 and I am 100% sure that part is setup correctly to get my Client ID and Resources.

-I set constants class name to Minimal.GPGSIds. -External Dependency Manager is 1.2.67 -All packages are up to date such as Version Control 1.15.7 -Apk builds and Main Scene loads as the only scene. -Click Setup Android GPSP tab -Force Resolve Everything passes, I build APK unsigned to use Debug Keystore copy apk to phone and install.

Load app and press Authenticate. every time I do this now 1.) Authentication failed 2.) button disappears and text reads "Authenticating..." with a blue screen indefinitely.

If I close the app and restart goes straight to point 2. If I close app and clear data and cache it repeats 1 then 2.

I have tried 2021.2.5 , 2020.3.21 and 2019.4.32 and GPSP 10.12, 10.14(fix ) and 10.14 release. No matter the combination of the three all now exhibit the exact same results. I am at a loss now, I am willing to test more just to get this working, really is there a way for me to test just the OAuth2 part of all this? How can I verify I am in fact sending the correct credentials? Or do I just need to be 100% sure? I am experience in Unity and not a new programmer but I am not too familiar or experienced in OAuth2.

DimaDDM commented 2 years ago

Same error https://forum.unity.com/threads/google-play-services-authenticate-giving-authentication-failed-developer-error-for-no-reason.1193323/

P.S. How downgrade from 10.13 to 10.12? I'm tyring twice and got same error

XanderQue commented 2 years ago

I used the same instructions as upgrading.

HOW TO UPGRADE ​If you have already integrated the plugin and want to upgrade it to a newer version, ​you must delete the Assets/GooglePlayGames folder, then import the new package.

​After upgrading, redo setup (click "Google Play Games | Android Setup" and/or ​"Google Play Games | iOS Setup" on the menu). Do this even if you had already done ​this before on this project.

IgorGalimski commented 2 years ago

Unity 2020.3.20f1 tried different version, but I got this error

DimaDDM commented 2 years ago

After few days i find solution tha works for me.

  1. Unity 2020.3.24f1
  2. Plugin version 10.14
  3. Code for init and show leaderboard (in my case)

image

image

image

Maybe this will helpful someone. I tried many options, not all of them worked. p.s. When updating the plugin from 10.13 to 10.14, you need to delete the duplicate* .plugin file from the GooglePlayGames folder, and kepp .androidlib file

image