Search code examples
androidfirebasefirebase-authenticationgoogle-signinandroid-developer-api

Google Sign In throws an exception com.google.android.gms.common.api.ApiException: 12500


I have a simple application written in Android, where I want to do Google Sign and then Firebase Authentication. I copy paste the code from official page.

val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
    .requestIdToken(getString(R.string.default_web_client_id))
    .requestEmail()
    .build()

if (requestCode == REQUEST_CODE_GOOGLE_SIGN_IN) {
    val task = GoogleSignIn.getSignedInAccountFromIntent(data)
    try {
        // Google Sign In was successful, authenticate with Firebase
        val account = task.getResult(ApiException::class.java)
        firebaseAuthWithGoogle(account.idToken!!)
    } catch (e: ApiException) {
        // Google Sign In failed, update UI appropriately
        Log.w("aaa", "Google sign in failed", e)
        // ...
    }
}

But this simple code is throwing an exception com.google.android.gms.common.api.ApiException: 12500:

What is an issue, I checked online sources everyone is saying add support email, add application icon, but to add application icon I need to go through the OAuth verification process, which asks a lot of data which I currently do not have as I just started to develop my application, please help I am trying to solve this issue already for 48 hours.


Solution

  • because at least it was working before I uploaded it to play store

    Problem (a feature called Play App Signing)

    It seems like the Google Play Store is signing your app instead of you, so Firebase detects a different signing key, and prevents authentication. Re-signing apps is a Google Play Store feature, and preventing apps signed by signing keys which you haven't verified from authenticating with Firebase is a Firebase feature.

    Solution

    Go to Google Play Store Console → Setup → App Signing → App signing key certificate, copy the SHA-1 certificate fingerprint.

    Then go to Firebase Console → Project Settings → Your Apps → Add Fingerprint → and paste the SHA1.

    What you are doing

    Telling Firebase to accept authentication requests generated from an app signed by the key handled by Google Play Store. It previously only accepted requests from an app signed by your locally signed app, where the key is stored on your computer.

    Copy SHA-1 from here:

    Play Console screenshot

    Paste SHA-1 as a fingerprint here:

    enter image description here