playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.46k stars 965 forks source link

Persistently getting SignInStatus.UISignInRequired when calling authenticate #2979

Closed shi-vy closed 3 years ago

shi-vy commented 3 years ago

Hi,

I've had the Play Games Plugin in my game for a long time, over multiple versions. Recently I tried to upgrade to 0.10.12, and I kept encountering this issue over a myriad of test devices and Google accounts. I rolled back the upgrade, and am back on 0.10.11 and it has now become a persistent issue.

Relevant auth code

    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
        .RequestServerAuthCode(false)
        .Build();

    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.DebugLogEnabled = true;
    PlayGamesPlatform.Activate();

    PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptOnce, result => {
        if (result != SignInStatus.Success)
        {
            LogFile.Info($"Failed to authenticate with PlayGames ({result})");

            var failReasonEnum = AuthenticationResult.Failed;
        }
    }

There is more to the code, handling the successful request, but that's not relevant here as I am constantly getting the result variable being SignInStatus.UiSignInRequired.

I looked at the code comments here which has the follow comments.

    /// The client attempted to connect to the service but the user is not signed in. The client may
    /// choose to continue without using the API. Alternately, if {@link Status#hasResolution} returns
    /// {@literal true} the client may call {@link Status#startResolutionForResult(Activity, int)} to
    /// prompt the user to sign in. After the sign in activity returns with {@link Activity#RESULT_OK}
    /// further attempts should succeed.

First things first, the client in my example is signed in. I guess this error should be returned when a user does not have an active Google Account or a Play Games account created...? I've tried on multiple Google accounts with Play Games accounts signed in. I've tried signing out and back into these accounts, I've tried factory resetting my device. Nothing has helped.

I have no idea what the second half of the comment section is trying to say. There is no hasResolution method that I can find... there is no startResolutionForResult method on anything I can find... I don't even understand the {@link ... } syntax. I guess it's all broken javadoc?

When I look at the logs in adb, I see this message pop up when I'm trying to authenticate

12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: APP NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY GAME SERVICES 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: This is usually caused by one of these reasons: 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: (1) Your package name and certificate fingerprint do not match 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: the client ID you registered in Developer Console. 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: (2) Your App ID was incorrectly entered. 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: (3) Your game settings have not been published and you are 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: trying to log in with an account that is not listed as 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: a test account. 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: To help you debug, here is the information about this app 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: Package name : com.[redacted] 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: Cert SHA1 fingerprint: [redacted] 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: App ID from manifest : [redacted] 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: Check that the above information matches your setup in 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: Developer Console. Also, check that you're logging in with the 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: right account (it should be listed in the Testers section if 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: your project is not yet published). 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: For more information, refer to the troubleshooting guide: 12-03 16:17:33.818 17431 23901 E PlayGamesServices[SignInAuthenticator]: **** http://developers.google.com/games/services/android/troubleshooting

All the information there, (the package name, SHA1, and App ID) are exactly correct and haven't changed for over 2 years.

I have started to try removing the whole Play Games SDK, and re-added it per the instructions in the README, but nothing is working.

Some other relevant info, I am targetting Android API Level 21 (Android 5), Proguard is enabled but I exclude basically everything in the com.google.android.gms.games.* namespace. I have tested on two devices, one running Android 11, the other Android 6. Three accounts on each, all having the same issue.

I hope someone can help, I legitimately am at a total loss for what has happened here.

Thanks.

shi-vy commented 3 years ago

I have been through all of the steps here: https://developers.google.com/games/services/android/troubleshooting

The metadata tags are fine, contents of the GooglePlayGamesManifest.plugin match exactly with what comes out in the ADB output above, I don't change anything after generating it via Google Play Games --> Setup --> Android Setup.

The package name is correct. This hasn't changed or been modified in years.

The certificate fingerprint is correct. The SHA1 fingerprint in the keystore used to sign the app is the same SHA1 fingerprint that shows up in the ADB output above, it is the same one that appears in the Google Play Console Dashboard and it is the same one that appears in the Google Cloud Console API Manager.

Test accounts aren't relevant to my situation as the game is published and is currently live in the store.

Double checked that my proguard-user.txt includes everything from here.

I'm really not sure what else to do.

Image of my resources is below, when it hit setup there is sets up and says Play Games has been set up correctly. The client ID there matches the client ID in the Play Console... everything literally matches everywhere.

image

olehkuznetsov commented 3 years ago

What is package name of your game?

shi-vy commented 3 years ago

com.halfbrick.brickwars

djmuhlestein commented 3 years ago

Same issue here. Everything matches. I can use playgames services fine until I add .RequestServerAuthCode(false) to my config. If that is present, I get the App not correctly configured error in the logs. I've tried regenerating oauth certs, tried both the upload and production certs etc. It's unclear how to debug what is actually wrong.

ozdemir08 commented 3 years ago

If you use a client id that belongs to another project, you will immediately see an error pop-up, saying "Web client id not associated with this game!". Apparently, this is not your case.

A potential cause of this is using a client id that belongs to the same project but is the wrong one. In the Configuration tab of Play Games Services on Play Console, you have the option to create a credential for Android and Game server. If you use an Android one instead of Game server as your web client id, the sign-in will be successful as long as you initialize your PlayGamesClientConfiguration in the simplest way: new PlayGamesClientConfiguration.Builder().Build(). However, when you add the .RequestServerAuthCode(false) bit there, it will fail with the long error message of APP NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY GAME SERVICES.

Please, take a look at it and check if you are using a Game Server one. Let us know if the issue still persists.

djmuhlestein commented 3 years ago

My particular issue, was that the web client ID I was mistaken to be the client id that is for the google play games services. That particular ID though, isn't even used in the GPGS setup... (It even says Web App Client ID (Optional): in other words, you don't need to specify the GPGS client ID that you find in the Play games console for GPGS to authenticate and work with leaderboards etc.

The web app client ID on the other hand, is the OAuth client ID for your web app (firebase in my case). The reason it is optional, is you only need it if you are going to call .RequestServerAuthCode. In this case, the web app client ID is used to grant that auth code and allow you auto pass the token to authenticate with your web app. So for me, when I put the client ID for my web app instead of the one for my GPGS key, wow, magically it solved the problem just like that.

javierron commented 3 years ago

You have to set up a Game Server credential and use that ClientID if you want RequestServerAuthCode() to work