googlesamples / google-services

A collection of quickstart samples demonstrating the Google APIs for Android and iOS
https://developers.google.com
Apache License 2.0
3.06k stars 2.53k forks source link

Google SignIn Fails with code 10 (on Android) #360

Closed sudarsangp closed 6 years ago

sudarsangp commented 6 years ago

Step 1: Describe your environment

Step 2: Describe the problem:

Throws Error after choosing Google account

com.google.samples.quickstart.signin W/SignInActivity: signInResult:failed code=10

Steps to reproduce:

  1. Clone the repository and Launch SignIn App (under Android)
  2. Click SignInActivity
  3. Click Google Sign In button
  4. Choose your Google Account
  5. Logs above error in Logcat
acrrono commented 2 years ago

After release to the store I found signin not working again and it turned out that you need to create a third key with your app's fingerprint from the Play Store developer console because google re-signs published builds with a different certificate. To sum it up you need to create four OAuth client ids in Google API console: 1 Web client id - this and only this one must be defined in your mobile app for all build types 3 Android client ids (with debug, release and publish fingerprints)

Thank you. This fixed my problem. After upload first bundle to internal test i started to get an error with google sign in. What i done to fix that problem:

  1. add all of the "android" cliend ids (for all fingerprints)
  2. add play signing fingerprint to firebase console
  3. get new google-services.json from firebase console
ABHINAVABHISHEK commented 2 years ago

First Create and add Android Fingerprint in Android Client ID

And Create A new Web Application OAuth Client ID

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .requestProfile()
                .requestIdToken(getString(WEB_APPLICATION_CLIENT_ID_FOR_OAUTH_2))
                .build();

Use Web Application OAuth Client ID 👍👍👍

moshequ commented 2 years ago

This solved it for me https://www.youtube.com/watch?v=SdYp5JdMvs0

erlangparasu commented 2 years ago

"Web Application" name confuse me, but it works

pfoof commented 2 years ago

Also watch out for this Key com.google.android.gms.games.APP_ID expected String but value was a java.lang.Float. The default value <null> was returned. - yes, use @string resources like in the guide

soniccat commented 1 year ago

In my case, everything worked with Client ID from https://console.cloud.google.com. But after adding requestServerAuthCode I started getting errorCode 10 and it turned out that I needed to use oauth_client from fireabse google-services.json which was a different string...

felixkrautschuk commented 1 year ago

I just came across this thread, as I see the same error in our app.

When I add the SHA1 from our release keystore to the Google Cloud Console, the signin process os working when running a release build on device or emulator. When running a debug build on emulator, I see this error code 10.

The other way around, when adding the SHA1 from the debug keystore, the sign in process stops working when running a release build.

So my question is: how can I make sure that I am able to test the login stuff in a debug build AND people using the live app (when it is released on play store) can use the sign in stuff at the same time? As I can only add one SHA1 to the Google Cloud Console.

Btw, I am not using Firebase. Thank you in advance!

HzwSunshine commented 1 year ago

When I tried to use the New Google Sign-In API (https://developers.google.com/identity/sign-in/android/sign-in-identity), I found that on system versions lower than Android 10, always Error: com.google.android.gms.common.api.ApiException: 10: Caller not whitelisted to call this API., but there is no such error on Android 10 and Android 11 and above phones. I'm currently using Google Sign-In for Android (legacy) (https://developers.google.com/identity/sign-in/android/sign-in) I've also never encountered such an error, I don't understand Why? My SHA1 is configured correctly

jaaywags commented 1 year ago

I was getting this error and I had checked the SHA's and Web Client stuff were all set up correctly. I must have checked this 20 times. Everything matched in firebase, google developer console, and google-services.json, but yet google sign in was not working.

I finally figured it out and wanted to post this for others (and probably my future self when I run across this again).

My issue was I have 2 firebase projects. One for stage, and one for prod. Stage worked fine but prod did not. Yes, I confirmed I had all the right SHA's set up and everything (sort of). I realized that the SHA I added to firebase was for my production keystore release version, but I was running the app locally in debug mode with my stage keystore file. I quick google on how to run it in release mode locally gave me this command:

react-native run-android --mode release

Everything is working now.

deepak-exiliensoft commented 1 year ago

hii all if you are facing the issue using google login with code 10,then follow the steps below you may find your solution 1.check your project connect to the firebase account 2.if you are connected with firebase account then just add to sha-1 and sha-256 in your firebase account. 3.download the google.json file and put in your app folder in project root folder

hope your problem might be solve happy coding!

stefanobrambilla commented 7 months ago

i have a problem with google login ONLY in Production/Android.

i use EXPO i use it WITHOUT FIREBASE. i receive in production/android "DEVELOPER_ERROR" error.

Into documentation i see that is always as misconfigured, but the only configuration we have is a fingerprint to add in Google Api Console.

i can't understand which fingerprint add for production.

FINGERPRINT on my google play console enter image description here

FINGERPRINT found in android studio with command gradle signinreport enter image description here

FINGERPRINT found with eas credentials enter image description here i try every fingerprint with the same result.

thanks in advanced

A help to workaround this problem

viethuy04 commented 7 months ago

For whom use the AppCenter to distribute the APK. The AppCenter by somehow overrides the release keystore from project, they use their own keystore. You can get this SHA1 from their keystore by downloading the apk and run keytool -printcert -jarfile 'path_to_apk'. You'd get the SHA1, then add the new Android Oauth Client ID with this SHA1. Then try again, this fixed my issue. Hope it helps!

Us3rL0sT commented 6 months ago

i have a problem with google login ONLY in Production/Android.

i use EXPO i use it WITHOUT FIREBASE. i receive in production/android "DEVELOPER_ERROR" error.

Into documentation i see that is always as misconfigured, but the only configuration we have is a fingerprint to add in Google Api Console.

i can't understand which fingerprint add for production.

FINGERPRINT on my google play console enter image description here

FINGERPRINT found in android studio with command gradle signinreport enter image description here

FINGERPRINT found with eas credentials enter image description here i try every fingerprint with the same result.

thanks in advanced

A help to workaround this problem

hey, u decided it ?

shahidkarimi commented 5 months ago

This is still a hot issue samtstern. Closing this makes no sense

darkokoa commented 4 months ago

After release to the store I found signin not working again and it turned out that you need to create a third key with your app's fingerprint from the Play Store developer console because google re-signs published builds with a different certificate. To sum it up you need to create four OAuth client ids in Google API console: 1 Web client id - this and only this one must be defined in your mobile app for all build types 3 Android client ids (with debug, release and publish fingerprints)

I think the publish fingerprints (sha1) of play store are the easiest for developers to miss.

IDENTICOSantiago commented 2 months ago

Hello, I have a similar problem, all this time I thought that the problem was when I published my application to the play store that it stopped working, since in APK and emulator it always worked but when I tried to log in with Google from my application it showed me an error 10, but I realized that it is something different and the problem was not with the play store. It's like the system crashes or something because sometimes it works and when it works it works everywhere but when it crashes or I don't know what happens it stops working in all types of environments and throws error 10.

I'm only using Google Cloud for now, but I plan to use FireBase if this problem continues, if anyone knows how I can solve this problem it would be very helpful.

I am using the SHA1 of the release that returns the signinReport of android studio in Google Cloud and from what I see the package name, the fingerprint and the id of the web type client are correct

Us3rL0sT commented 2 months ago

the solution is to enter 3 sha-1: debug, release, and play market keys into the project setting firebase. Enter the key from the play market in the api credentials oauth 2.0, it will be written that it is confirmed. Create a web application in oauth 2.0 and use the client - id from this web client.

IDENTICOSantiago commented 2 months ago

@Us3rL0sT Yes, I managed to solve it by adding another credential with the SHA-1 Certificate of the application signing key from the Google console to Google Cloud, thank you.

Tananga commented 1 month ago

Im trying to login with google but Im always getting this stupid error 10. Im still fighting and today I wasted whole day to deal with it without success. I dont published my app yeat. Im not using firebase. Im using only flutter.

@IDENTICOSantiago can you say exacly what you did?