capacitor-firebase-auth
capacitor-firebase-auth copied to clipboard
'Google Sign In Failure' error on prompt dismissal (Android)
I am getting a Google Sign In Failure
error reported from the plugin when I dismiss the Google sign in prompt. I am able to successfully sign in using the Google provider - I only get this error when I dismiss the sign in prompt. I would expect no error, or maybe the Firebase error code auth/popup-closed-by-user
, which is the error thrown when you dismiss the sign-in dialog on the web.
I believe this is happening because of this function in GoogleProviderHandler.java
:
@Override
public void handleOnActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(GOOGLE_TAG, "Google SignIn activity result.");
try {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = task.getResult(ApiException.class);
if (account != null) {
Log.d(GOOGLE_TAG, "Google Sign In succeed.");
AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
this.plugin.handleAuthCredentials(credential);
return;
}
} catch (ApiException exception) {
// Google Sign In failed, update UI appropriately
Log.w(GOOGLE_TAG, GoogleSignInStatusCodes.getStatusCodeString(exception.getStatusCode()), exception);
plugin.handleFailure("Google Sign In failure.", exception);
return;
}
plugin.handleFailure("Google Sign In failure.", null);
}
The exception is throw from the task.getResult(ApiException.class)
line, because it does not first check the resultCode
for the cancel case.
https://stackoverflow.com/questions/50447430/google-sign-in-apiexception-12501-when-dismissing-the-sign-in-dialog
Error logcat
E/Capacitor/Plugin: Google Sign In failure.
com.google.android.gms.common.api.ApiException: 12501:
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@@18.0.0:9)
at com.baumblatt.capacitor.firebase.auth.handlers.GoogleProviderHandler.handleOnActivityResult(GoogleProviderHandler.java:85)
at com.baumblatt.capacitor.firebase.auth.CapacitorFirebaseAuth.handleOnActivityResult(CapacitorFirebaseAuth.java:178)
at com.getcapacitor.Bridge.onActivityResult(Bridge.java:770)
at com.getcapacitor.BridgeActivity.onActivityResult(BridgeActivity.java:212)
at android.app.Activity.dispatchActivityResult(Activity.java:8294)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5248)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5296)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2229)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8034)
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:1076)
Same issue here !
Same issue here. The front-end should be able to figure this out from the exception in plugin.handleFailure("Google Sign In failure.", exception), but capacitor doesn't seem to pass that exception back to the javascript layer. Maybe this plugin should send the exception code through instead
same issue as well. @baumblatt thoughts? :)
is this issue still open.. i can fix it
Yes. I am seeing the error :)
ok
@jeremyrajan Give me GoogleServcie.json file and other details please
Same problem