capacitor-firebase-auth icon indicating copy to clipboard operation
capacitor-firebase-auth copied to clipboard

Instance of firebase.auth.Auth must be passed as an argument

Open gabriel-imascono opened this issue 5 years ago • 2 comments

Hello, I'm trying to implement this plugin in a project but I'm facing an error I'm not able to fix. I've followed all the steps detailed in this repo (twice) and when I try to call the cfaSignIn method this shows in logcat:

2020-08-19 14:46:39.077 22933-23065/com.imascono.latorreoutlet E/Capacitor: JavaScript Error: {"type":"js.error","error":{"message":"Uncaught Error: Either an instance of firebase.auth.Auth must be passed as an argument to the firebase.auth.PhoneAuthProvider constructor, or the default firebase App instance must be initialized via firebase.initializeApp().","url":"http://localhost/static/js/2.ed6af05b.chunk.js","line":2,"col":1000021,"errorObject":"{\"code\":\"auth/argument-error\",\"message\":\"Either an instance of firebase.auth.Auth must be passed as an argument to the firebase.auth.PhoneAuthProvider constructor, or the default firebase App instance must be initialized via firebase.initializeApp().\"}"}}
2020-08-19 14:46:39.081 22933-22933/com.imascono.latorreoutlet E/Capacitor/Console: File: http://localhost/static/js/2.ed6af05b.chunk.js - Line 2 - Msg: Uncaught Error: Either an instance of firebase.auth.Auth must be passed as an argument to the firebase.auth.PhoneAuthProvider constructor, or the default firebase App instance must be initialized via firebase.initializeApp().

I'm not sure why it is trying to use the PhoneAuthProvider when I'm only using Google:

cfaSignIn("google.com").subscribe((user: User) =>
  console.log(user.displayName)
);

This is my capacitor.config.json:

"CapacitorFirebaseAuth": {
  "providers": ["google.com"],
  "languageCode": "en",
  "nativeAuth": false,
  "permissions": {
    "google": ["profile"]
  }
}

gabriel-imascono avatar Aug 19 '20 12:08 gabriel-imascono

Hi Grabiel,

Despite that you are seen this at logcat, maybe this is a Web Typer problem.

Did you initialize your firebase application? Please review the firebase documentation here

Hope this help you, looking forward to hearing from you.

Best regards, Bernardo Baumblatt

baumblatt avatar Aug 25 '20 19:08 baumblatt

@gabriel-imascono I had the same issue until I implemented email & password sign in method using AngularFire. I suppose is because AngularFire needs Firebase initialization through AngularFireModule.initializeApp(firebaseConfig)

joseph-navant avatar Sep 16 '20 10:09 joseph-navant