Why do I get com.google.android.gms.common.api.ApiException: 10:?

AndroidFirebase Authentication

Android Problem Overview


private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
    try {
        GoogleSignInAccount account = completedTask.getResult(ApiException.class); //exception is here

        // Signed in successfully, show authenticated UI.
        System.out.println("google token ---> " + account.getIdToken());
    } catch (ApiException e) {
        // The ApiException status code indicates the detailed failure reason.
        // Please refer to the GoogleSignInStatusCodes class reference for more information about this error.
        e.printStackTrace();
    }
}

Android Solutions


Solution 1 - Android

Quoting the documentation: > Certain Google Play services (such as Google Sign-in and App Invites) > require you to provide the SHA-1 of your signing certificate so we can > create an OAuth2 client and API key for your app.

If you are using Firebase and try on the debug app :

1. First, get your SHA-1 debug key :

  1. Click on Gradle (From Right Side Panel, you will see Gradle Bar)
  2. Click on Tasks
  3. Click on Android
  4. Double Click on signingReport (You will get SHA-1 and MD5)

2. Add your key to your Firebase project :

  1. Go to Project settings -> SHA certificate fingerprints -> Add SHA-1 key of debug app.

  2. Then you can update your google-services.json file in your Android project.

It's works for me.

Solution 2 - Android

This status code means that you are providing unknown server client id. In https://console.developers.google.com/apis/credentials in your project you might need to generate: OAuth client ID -> Web Application and use this web application client id here:

val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestIdToken(webApplicationClientId)
        .requestEmail()
        .build()

Solution 3 - Android

I have solved this problem using these steps:

1). Goto https://console.developers.google.com/ and delete (Android Client) if it is created.

2). Click on Create Credential and click on OAuthClientID and select android

3). copy and paste your SHA 1 fingerprint

4). type your package name then saved

5). Goto console.firebase.com

6). download google-service.json move it into your project into app directory

7). Open google-service.json and find out client id type 3 and use it as default_web_client_id

8). Run your App

Solution 4 - Android

My problem was trying to use Google Sign-In yet I had accidentally enter the wrong SHA1 in Firebase. Try running Gradle > Your app name > Tasks > android > signingReport, get your SHA1 key and compare it with the one on Firebase. If they are different, change the Firebase SHA1 key to match the one you got from the signingReport. Don't forget to also download the google-services.json afterwards.

Solution 5 - Android

The ApiException Error Code 10 is a developer error. You get this error when your firebase app is not well configured. One sure case is when you do not supply the SHA1 fingerprint for your android app when you want to use Firebase authentication with Google Signin. (It is a requirement for Google Signin). So supply the SHA1 fingerprint, download the google-services.json configuration file to your app folder and build. You should be good to go.

> Google sign-in is automatically configured on your connected iOS and web apps. To set up Google sign-in for your Android apps, you need to add the SHA1 fingerprint for each app on your Project Settings.

Check this out Common Status Error Codes

Solution 6 - Android

I have this thing in 2-3% of the occasions in production and it works seamlessly for everyone else.

Given the sheer amount of problems and differing answers this is causing, it's fair to say that this is a problem on behalf of firebase. They've implemented a catch-all error routine that is just bad api design. The api must point to the problem where it fails.

A long term solution is to convince firebase that this is bad-api design and they need to do better.

We're strong together.

Please write a support ticket to firebase roughly with this:

> Hey Firebase Support, > > i have a com.google.android.gms.common.api.ApiException: 10 in my app. > > The problem for me - and for a lot of people all over the forums - is > that your api seems to have a catch-all error routine that roughly > speaking is saying "something went wrong, please fix it". > > You could release your support team and a lot of people from headache > if you would fix this. > > The API should be able to figure what's wrong and give a better error > message from the context where it occurs. > > It's really a burden and I think that since firebase has a > quasi-monopoly on these matter on Android it's your obligation to do > better. > > While this is obviously not your fault, I'd like to encourage you to > escalate this problem. > > It's fundamentally bad api design and harms an otherwise great > product. > > Thanks anyway.

Solution 7 - Android

In my case the problem was with the SHA1 and google-services.json file

i solved the problem follow this steps:

1.- Open https://console.cloud.google.com/apis/credentials and delete file at OAuth 2.0 Client IDs

2.- Open https://console.firebase.google.com/ clic gear icon -> Proyect Settings -> Select your Android App -> add fingerprint -> save -> and download google-services.json file

3.- Open your android proyect and replace de google-services.json file -> clic Sync Proyect with Gradle Files

4.- The new default_web_client_id at values works fine for me and solved the problem

Solution 8 - Android

Don`t forget to add

<application
...
    <meta-data
    android:name="com.google.android.gms.wallet.api.enabled"
    android:value="true" />
...
</application>

under your manifest file application tag. In my case problem was because of absent this lines.

Solution 9 - Android

that is because you are using the wrong default_client_token_id. to solve this go to the JSON file downloaded from firebase and open it: your client_id is located right after the "certificate_hash":xxxxxxzxzxzzzxzxzxzxzxzx.... good luck :) and I hope it helped.

Solution 10 - Android

If you remove this line it will work:

System.out.println("google token ---> " + account.getIdToken());

This is because you don't have the request to the idToken:

.requestIdToken(getString(R.string.google_app_id))

where the app_id will have the value of "OAuth client ID -> Web Application"

Solution 11 - Android

When you are doing setup of google login, it normally take Signed keystore hash key. So try with signed APK then it will work. For debugging try to add your debug SHA key on google console.

Solution 12 - Android

I guess the question is answered. But for me it was a little different. So if some googlers come along this and may have the same problem as I had:

Special Case

  • multiple firebase projects
  • client ids whitelisted
  • installed app through app sharing can't sign up with google

In case anybody is using multiple firebase projects for one application (i.e. for different flavors) and has whitelisted the "external" client ID in Google-Authentication in one project.

Then the solution is, to generate new credentials in the Google APIs console of the "master" / whitelisted project with the sha-1 (found in app sharing) of the other project.

Add new credentials to API Console

  1. Go to Google APIs of whitelisted project
  2. Create new OAuth Client ID
  3. Add everything needed, also package name of other project
  4. Paste the SHA-1 hash from App Sharing of other project

Done

Sorry for my bad english. It's not my mother tongue.

Solution 13 - Android

ApiException 10 is a DEVELOPER_ERROR, which means something's wrong with your app configuration.

This answer worked for me, but then I realized our app authenticates with a backend server. So, if your app authenticates with a backend server, you only need to use the web application client ID. But you still need to create client ID of Android type or you're going to get ApiException 12500 . You can read more about it from the documentation. (note that the link has authuser=0)

Solution 14 - Android

val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
    .requestIdToken(OAUTH_2_CLIENT_ID)
    .requestEmail()
    .build()
val mGoogleSignInClient = GoogleSignIn.getClient(this, gso)
val signInIntent = mGoogleSignInClient.signInIntent
startActivityForResult(signInIntent, GOOGLE_LOGIN)

OAUTH_2_CLIENT_ID is Web client (auto created by Google Service). Not Android

Solution 15 - Android

This Error because of Wrong Client Id

GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(getString(R.string.default_web_client_id))
                    .requestEmail()
                    .build();

You must pass your server's client ID to the requestIdToken method.

client Id can be found eaisly in google-services.json file

{
      "client_id": "",
      "client_type": 3
    }

No need to go to Credentials page in the GCP Console.

Please to follow instructions from

https://firebase.google.com/docs/auth/android/google-signin

Solution 16 - Android

If you came here because of an error with the Google Login iOS & Android Unity library, this is what helped for me.

I changed the Google project and kept getting ApiException: 10. I later found out that it was because you need to use a web client, not an Android one.

If you want to check if you have a web client or an Android one, open the client_secret_(some text).apps.googleusercontent.com.json file - if it starts with {"web" it's a web client.


Step by step instructions for replacing the client:

  1. Remove the client_secret_(some text).apps.googleusercontent.com.json file from your Unity project. If you have a plist file (for iOS) too, don't remove it.
  2. Go here, click "Configure a project" and configure an Android client.
  3. Go to the Google Cloud Credentials page (select your project if necessary) and download the auto-generated web client.
  4. Click Assets > External Dependency Manager > Android Resolver > Force Resolve.
  5. Change the client ID passed to LCGoogleLoginBridge.InitWithClientID in the script where you call this function.
  6. Build and see if the issue has been resolved.

Solution 17 - Android

In my case, it resolved by reconnect my Android Studio to Firebase.

Solution 18 - Android

I was getting the same error but I obtained the web client token from Google Cloud Console and placed it right where the GoogleSignInOptions is declared. Replace the

.requestIdToken("getString(R.string.default_web_client_id)")

with the web client ID for your particular Google Cloud project.

Solution 19 - Android

I were using this command from documentation ...

 keytool -exportcert -keystore ~/.android/debug.keystore -list -v

i just change it to

 keytool -exportcert -keystore ./.android/debug.keystore -list -v

and using SHA-1 and copy it into firebase android section. it just wokrs fine.

Solution 20 - Android

If you don't use your own backend server you don't need to provide OAuth 2.0 client id (as it said here). Of course check that you provided correct SHA-1 code, but remember that you are providing the release variant SHA-1 key, so this error might appear when you are trying to use Google SignIn with debug app variant. So you have 2 options:

  1. Build and run release APK
  2. Add your debug SHA-1 key to the Firebase console and then you'll be able to run your debug APK without this exception

Solution 21 - Android

Possible solve:

If you once renamed project's package check that package name in AndroidManifest.xml and applicationId in app gradle file are the same. It helped me when I named applicationId like my application package

Solution 22 - Android

For me the mistake was simple. I had initialized google signin options outside the oncreate callback.

Solution 23 - Android

From my experience it is a problem with SHA1. Solution which worked for me:

  1. Delete OAuth listings if you have created any (probably optional)
  2. Launch this command in your project terminal keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android and copy SHA1 fingerprint.
  3. Go to Firebase console, click gear on your project and delete old fingerprint's. Replace them with the one you copied during step 2
  4. Download new google-services.json file and replace the old one
  5. Sync project with Gradle files.

Should be working :)

Solution 24 - Android

I solve this problem by redo my Firebase Auth connection again.

  1. Click the right top little square to login to your google account
  2. Go to the Tool - > Firebase
  3. Select the Authentication
  4. Connect

After that it may say you are already connect, but you need to update the connection. After that it works fine. I think sometime Android Studio mixed up with different Firebase account.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionArsen BudumyanView Question on Stackoverflow
Solution 1 - AndroidJohnnyView Answer on Stackoverflow
Solution 2 - AndroidbojanView Answer on Stackoverflow
Solution 3 - AndroidDanish AhmedView Answer on Stackoverflow
Solution 4 - AndroidAndrew ChelixView Answer on Stackoverflow
Solution 5 - AndroidlandrykapelaView Answer on Stackoverflow
Solution 6 - AndroidshreddingView Answer on Stackoverflow
Solution 7 - Androidvicente esparzaView Answer on Stackoverflow
Solution 8 - AndroidРома БогданView Answer on Stackoverflow
Solution 9 - Androiduser10702679View Answer on Stackoverflow
Solution 10 - AndroidVitor ReaisView Answer on Stackoverflow
Solution 11 - AndroidAbeer IqbalView Answer on Stackoverflow
Solution 12 - AndroidJacksOnF1reView Answer on Stackoverflow
Solution 13 - AndroidzeenosaurView Answer on Stackoverflow
Solution 14 - AndroidDaFengAView Answer on Stackoverflow
Solution 15 - AndroidIslam AlshnaweyView Answer on Stackoverflow
Solution 16 - AndroidNarek TorosyanView Answer on Stackoverflow
Solution 17 - AndroidKirill_codeView Answer on Stackoverflow
Solution 18 - AndroidMuiruriView Answer on Stackoverflow
Solution 19 - AndroidSyed Moamber RazaView Answer on Stackoverflow
Solution 20 - Androidthe korovayView Answer on Stackoverflow
Solution 21 - AndroidNikView Answer on Stackoverflow
Solution 22 - AndroidOtienoSamwelView Answer on Stackoverflow
Solution 23 - AndroidGiedrius ŠlikasView Answer on Stackoverflow
Solution 24 - AndroidJosepharaohView Answer on Stackoverflow