1
votes

I'm trying to add Firebase oauth to my project, using google and facebook.

Plugins I've added to my project:

  • cordova-plugin-browsertab 0.2.0 "cordova-plugin-browsertab"
  • cordova-plugin-buildinfo 2.0.1 "BuildInfo"
  • cordova-plugin-compat 1.2.0 "Compat"
  • cordova-plugin-inappbrowser 1.7.2 "InAppBrowser"
  • cordova-plugin-whitelist 1.3.3 "Whitelist"
  • cordova-universal-links-plugin 1.2.1 "Universal Links Plugin"

And I'm using Android 6.2.3 as my platform right now, I'm thinking about adding iOS later.

My problem is that I'm getting auth/redirect-cancelled-by-user as response for every login request using the firebase service.

I've followed the instructions on the official tutorial. I've added:

<universal-links>
    <host name="URL" scheme="https" />
    <host name="package name" scheme="https">
        <path url="/__/auth/callback" />
    </host>
</universal-links>

Into my config.xml file.

1
Make sure you are substituting your authDomain in package_name. Also make sure your FDL domain is also added in the universal-links. If you happen to use a custom authDomain, make sure you use that one instead of the .firebaseapp.com one.bojeil
I've already checked that, I'm not using a custom AuthDomain.Diego Portilla Tejera
There is clearly something wrong in your link interception. Try to see if you are getting the incoming link: universalLinks.subscribe(null, function(event) {console.log(event.url);});bojeil
I've already tried that, nothing on log, I don't know if I'm placing it in the right place. I'm doing the subscribe in the index.js at onDeviceReadyDiego Portilla Tejera
If that is logging nothing then there is a problem with your redirect setup. Can't tell which part with the information available. Try to get a basic web to mobile redirect working with that plugin.bojeil

1 Answers

0
votes

Hi I have spend 5 hours to find the solution of this. I am using PhoneGap Build. The problem is Universal-links tag is not copied to AndroidManifest.xml. So the solution is

  1. Install cordova-universal-links-plugin-fix
  2. If you want to keep universal-links tag in config.xml keep it. But also add this to config.xml

In widget tag on top add

xmlns:android="http://schemas.android.com/apk/res/android"

The add following code anywhere in config.xml I prefer before plugins or beside unvirsal-links tag

<config-file target="AndroidManifest.xml" parent="/manifest/application/activity">
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:host="****-***.firebaseapp.com" android:pathPrefix="/__/auth/callback" android:scheme="https" />
    </intent-filter>
</config-file>

Now when app is build either with phonegapbuild or local cordova CLI, it copies the universal-links data which was supposed to be in manifest file. When app runs and firebase.auth().getRedirectResult() is called it will not give any error which was something like

auth/cancelled by user. The redirect was cancelled by user before finalizing

User building app using cordova CLI please after running cordova build android make sure you have the above intent-filter tag under activity tag in the manifest file.