firebase / firebaseui-web

FirebaseUI is an open-source JavaScript library for Web that provides simple, customizable UI bindings on top of Firebase SDKs to eliminate boilerplate code and promote best practices.
https://firebase.google.com/
Apache License 2.0
4.58k stars 1.06k forks source link

Sign in with Facebook on Cordova (iOS) doesn't work #565

Open RohanTalip opened 5 years ago

RohanTalip commented 5 years ago

[REQUIRED] Describe your environment

Partial output from cordova info :

Node version: v10.15.0
Cordova version: 8.1.1

...

iOS platform:

Xcode 10.1
Build version 10B61

My Cordova plugins:

$ cordova plugin list
cordova-plugin-browsertab 0.2.0 "cordova-plugin-browsertab"
cordova-plugin-buildinfo 2.0.2 "BuildInfo"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-customurlscheme 4.3.0 "Custom URL scheme"
cordova-plugin-firebase 2.0.5 "Google Firebase Plugin"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-keyboard 1.2.0 "Keyboard"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-universal-links-plugin 1.2.1 "Universal Links Plugin"

Note that cordova-universal-links-plugin is really cordova-universal-links-plugin-fix.

Slightly massaged output of npm list | grep cordova in my Cordova directory:

[REQUIRED] Describe the problem

Steps to reproduce:

Attempting to sign in with Facebook just redirects back to my (Cordova) app after the login process on facebook.com, with no change to the FirebaseUI auth screen (i.e. no loading indicator), nor anything being logged, even though I am logging to the console in the signInFailure and signInSuccessWithAuthResult callbacks.

I am normally using the cordova-plugin-wkwebview-engine plugin to fix some layout issues but I removed it temporarily to get back to a more standard configuration. When the cordova-plugin-wkwebview-engine plugin is installed, after indicating on Facebook's web page that I want to continue (to sign in), the web view redirects to an m.facebook.com hostname with something like this in the source:

<html><head><script type="text/javascript">window.location.href="https:\/\/auth.xyz.com\/__\/auth\/handler?code=AQB123&granted_scopes=email\u00252Cpublic_profile&denied_scopes&state=AM123m#_=_";</script></head></html>

... and stays there. Clicking on the "Done" button at the top left in Safari will take me back to my Cordova app, but I am still not signed in.

The reason that I included the HTML source above is that the backslashes seem suspicious, but that could be a red herring.

Please note that signing in via Facebook is working in a regular web app, and signing in via Google is working in my Cordova app.

The same thing happens in an iPhone simulator (started via Xcode) as well as on a real iPhone.

The "embedded browser OAuth flow" setting is enabled in "Facebook Login" settings for my app.

Have I misconfigured something or is signing in with Facebook broken for everyone on Cordova / iOS?

Relevant Code:

const uiConfig = {
  signInOptions: [
    firebase.auth.GoogleAuthProvider.PROVIDER_ID,
    firebase.auth.FacebookAuthProvider.PROVIDER_ID,
    firebase.auth.EmailAuthProvider.PROVIDER_ID,
  ],
  privacyPolicyUrl: "https://www.xyz.com/privacy",
  callbacks: {
    signInFailure: function(error) {
      console.error("signInFailure(): error =", error);
    },
    signInSuccessWithAuthResult: function(authResult, redirectUrl) {
      console.log("signInSuccessWithAuthResult(): authResult =", authResult, ", redirectUrl =", redirectUrl);
      return true;
    },
  },
};
    let authUi = firebaseui.auth.AuthUI.getInstance();
    if (!authUi) {
      authUi = new firebaseui.auth.AuthUI(firebase.auth());
    }

    if (authUi.isPendingRedirect()) {
      console.log("isPendingRedirect() is true");
    }

    authUi.start("#firebaseui-auth-container", uiConfig);
adamdupuis commented 4 years ago

I'm also experiencing a similar issue with Facebook and Twitter only on iOS. When the user signs in and is taken back to the app, nothing happens. Signing in with Google and Email seem to work, however.

bojanbizjak commented 4 years ago

When on iOS the user signs in with Google or Microsoft and is taken back to the app, nothing happens; The firebase Web UI page with the providers reappears. A spinner that is supposed to indicate that the application is continuing sign-in process does not appear. "cordova": "9.0.0", "cordova-ios": "6.0.0". -> behaves exactly the same with "cordova": "9.0.0", "cordova-ios": "5.1.1" + cordova-plugin-wkwebview-engine.

We have tried all the possible plugins required from the firebase cordova auth, which are described here: https://firebase.google.com/docs/auth/web/cordova

Signing in with Apple and Email is working.

Everything works smoothly on the Android platform. Also in the browser on the Firebase Hosted website.