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

半世苍凉 提交于 2020-12-13 03:33:46

问题


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.


回答1:


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:

Paste SHA-1 as a fingerprint here:



来源:https://stackoverflow.com/questions/64587610/google-sign-in-throws-an-exception-com-google-android-gms-common-api-apiexceptio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!