Thaina / google-signin-unity

Google Sign-In API plugin for Unity game engine. Works with Android and iOS.
Other
29 stars 9 forks source link

[Android] Should not get null account #11

Closed SackMaggie closed 1 month ago

SackMaggie commented 1 month ago

When calling sign in the popup for select account appear but after select an account to sign in the error appear.

image

Changing to different google account -> nothing change

log signin_error_android.log

Environment Unity 2023.2.20 Editor

SackMaggie commented 1 month ago

I think the warning Should not get null account is coming from this line of code

image

In GoogleSignInImpl line 145

SackMaggie commented 1 month ago

Here's how I call Sign in

SignInSilently is always false

        public async Task<GoogleSignInInfo> SignInAsync()
        {
            try
            {
                if (!IsSupported())
                    throw new PlatformNotSupportedException();

                SetGoogleConfiguration();
                googleSignInTask = SignInSilently ? GoogleSignIn.DefaultInstance.SignInSilently() : GoogleSignIn.DefaultInstance.SignIn();

                GoogleSignInUser googleSignInUser = (await googleSignInTask);

                Debug.LogWarning(Newtonsoft.Json.JsonConvert.SerializeObject(googleSignInUser));

                googleSignInInfoCache = new GoogleSignInInfo(googleSignInUser);
                return googleSignInInfoCache;
            }
            catch (TaskCanceledException)
            {
                Debug.LogWarning("User canceled");
                throw;
            }
            catch (GoogleSignIn.SignInException e)
            {
                Debug.LogError("Got Error: " + e.Status + " " + e.Message);
                Debug.LogException(e);
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }

        private void SetGoogleConfiguration()
        {
            GoogleSignIn.Configuration ??= new GoogleSignInConfiguration
            {
                WebClientId = WebClientId,
#if UNITY_EDITOR || UNITY_STANDALONE
                ClientSecret = ClientSecret,
#endif
                RequestIdToken = true,
                RequestEmail = true,
                UseGameSignIn = false,
            };
        }
Thaina commented 1 month ago

Well, I think I should also log the result code too. But this problem most likely came from fingerprint config or webclientId config I think. It seem it didn't get the account which is the behaviour from that kind of problem

Have you try config fingerprint and webclientId in google cloud console? And did you put all fingerprint from your keystore and playstore keystore already?

SackMaggie commented 1 month ago

Well, I think I should also log the result code too. But this problem most likely came from fingerprint config or webclientId config I think. It seem it didn't get the account which is the behaviour from that kind of problem

Have you try config fingerprint and webclientId in google cloud console? And did you put all fingerprint from your keystore and playstore keystore already?

Thanks, I've fixed the issue by adding new OAuth with type Android and config SHA-1 fingerprint just like you said.