6

I have followed all the steps listed here: https://firebase.google.com/docs/auth/web/cordova, verified all the information but I am still getting the error below.

code: "auth/redirect-cancelled-by-user", message: "The redirect operation has been cancelled by the user before finalizing."
  1. I have the correct config information in my app
  2. My firebase config matches my firebase's console's config.
  3. I have the correct dynamic link.
  4. I have installed all the required plugins
  5. SHA certificate fingerprints are added.
  6. Project has been given the name under google login settings in Firebase console.

Here is how I'm calling google login:

consturctor has public afAuth: AngularFireAuth. And couple relevant imports are:

import * as firebase from 'firebase/app';
import { AngularFireAuth } from 'angularfire2/auth';

// signInWithGoogle.
  signInWithGoogle(): void {
    this.showLoading();
    if (this.platform.is('android')) {
      console.log("android");
      this.provider = new firebase.auth.GoogleAuthProvider();
      this.afAuth.auth.signInWithRedirect(this.provider)
        .then(function () {
          return firebase.auth().getRedirectResult();
        })
        .then((result: any) => {
          if (result) {
            this.handleUser(result);
          }
        })
        .catch((error: any) => {
          this.hideLoading();
          var errorMessage = error.message;
          console.log("android login error: ", error);
        });
    }
    if (this.platform.is('core')) {
      console.log("in core");
      this.provider = new firebase.auth.GoogleAuthProvider();
      this.afAuth.auth.signInWithPopup(this.provider)
        .then((result: any) => {
          if (result) {
            this.handleUser(result);
          }
        })
        .catch((error: any) => {
          this.hideLoading();
          var errorMessage = error.message;
          console.log("error: ", error);
        });
    }
  }

Above is my complete method.

Below is a test project so I'll show all the settings:

<universal-links>
    <host name="bhb7m.app.goo.gl" scheme="https" />
    <host name="test1-2366d.firebaseapp.com" scheme="https">
        <path url="/__/auth/callback" />
    </host>
</universal-links>
<preference name="AndroidLaunchMode" value="singleTask" />

Dynamic Link Android Settings

Webapp config Android Menifest

I guess I must be missing a step because I can't get it to work at all.

12
  • When you finish sign in, does it close the Chrome Custom tab (where you signed in to the OAuth provider) on its own or does it remain open until you manually close it (click the close button)? Also try to check you are detecting the incoming link correctly: universalLinks.subscribe(null, function (eventData) {console.log(eventData.url);}); If not there may be an issue with your FDL configuration for some reason.
    – bojeil
    Commented Jan 2, 2018 at 1:34
  • bojeil Thank you. It closes the chrome custom tab automatically.
    – Noman
    Commented Jan 2, 2018 at 1:37
  • Could my SHA being used in other projects effect this?
    – Noman
    Commented Jan 2, 2018 at 1:38
  • If it closes automatically, it means FDL is configured correctly. However, there could be an issue with your config.xml or JS code. can you check universalLinks.subscribe(null, function (eventData) {console.log(eventData.url);}); ? you want to ensure the plugin is detecting the incoming link.
    – bojeil
    Commented Jan 5, 2018 at 0:00
  • bojeil, I'm not sure how to call that command in ionic2.
    – Noman
    Commented Jan 5, 2018 at 1:20

1 Answer 1

2

The problem was with dependencies. I updated to Cordova 8.0 and then I started to get build errors.

4
  • You updated to Cordova 8.0 and that did solve your problem? Or it was what caused the problem, and you solved the problem by downgrading again? What was the nature of the problem with dependencies?
    – user9315861
    Commented Mar 14, 2018 at 4:25
  • Yeah, updating to Cordova 8.0 was the problem. I didn't put those relevant logs. And yes, downgrading fixed the problem. I think I would get errors when I did cordova prepare -verbose.
    – Noman
    Commented Mar 14, 2018 at 10:09
  • Which version did you downgrade to? Commented Apr 16, 2018 at 14:05
  • Downgraded to 7.
    – Noman
    Commented Apr 16, 2018 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.