CodetrixStudio / CapacitorGoogleAuth

Capacitor plugin for Google Auth. Lightweight & no dependencies.
MIT License
282 stars 154 forks source link

Android Sign In Fails With "com.google.android.gms.common.api.ApiException: 10:" #87

Open tylerku opened 3 years ago

tylerku commented 3 years ago

(see bottom for environment info)

I am trying to get google sign in working on both Android and iOS. I got it working on iOS pretty easily but the Android version is having issues. So I'm getting the com.google.android.gms.common.api.ApiException: 10: exception in the console when I call GoogleAuth.signIn(). I've gone through all the issues I can find on the subject and still haven't had any luck. Here is what I've done.

1) Added my debug and production SHA-1 fingerprints to my firebase project (which auto generates them in the corresponding Google Console project). 2) Added the google-services.json file to the root level of my project. 3) Added all the dependencies to my build.gradle that the firebase docs mentions.. as well as the ones that the google sign in docs mention

    dependencies {
        ....
        implementation platform('com.google.firebase:firebase-bom:26.5.0')
        implementation 'com.google.firebase:firebase-analytics'
        implementation 'com.google.firebase:firebase-auth'
        implementation 'com.google.android.gms:play-services-auth:19.0.0'
    }

4) Added the other code snippets as explained by Firebase console when adding an android app. 5) Followed all the steps in the README (always using the web client id from google console as the client id referred to in the README steps) 6) Added a support email address in both Google console and Firebase console. 7) Turned on Google Sign In in the Firebase project settings

I'm really at a loss as to what else I can try to get rid of this ApiException: 10. I've read that it usually means that my project is not configured correctly, but I've looked over the configuration multiple times and it seems right to me so I thought I'd ask for help. Any idea what I may be missing? I really appreciate it

Here's the full stack trace when the error is thrown:

/Capacitor/Plugin: Something went wrong
    com.google.android.gms.common.api.ApiException: 10: 
        at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(com.google.android.gms:play-services-base@@17.1.0:4)
        at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(com.google.android.gms:play-services-auth@@19.0.0:9)
        at com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.handleOnActivityResult(GoogleAuth.java:73)
        at com.getcapacitor.Bridge.onActivityResult(Bridge.java:776)
        at com.getcapacitor.BridgeActivity.onActivityResult(BridgeActivity.java:214)
        at android.app.Activity.dispatchActivityResult(Activity.java:7454)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4353)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4402)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Android SDK: Android 11.0 (R) API Level 30

r614 commented 3 years ago

Facing something similar, did you manage to fix it?

cyril-colin commented 3 years ago

Same issue here :/

image

cyril-colin commented 3 years ago

I fixed it ! By following these steps : https://stackoverflow.com/a/49800546

luckyboykg commented 3 years ago

Finally, I fixed this issue.

From my side: It's just about the SHA1 fingerprint issue.

  1. I get the "SHA-1 certificate fingerprint" from Google Play Console => App Integrity
  2. I paste this key to "SHA certificate fingerprints" on SDK setup and configuration in Firebase for my Android App => Save => Download the file google-services.json.
  3. I copy the "client_id" which "client_type" is 3. And copy it as the readme of this plugin.

=> Everything working normally from my side.