firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.75k stars 872 forks source link

Firebase: Error (auth/argument-error) #7882

Closed lakshyarawat1 closed 5 months ago

lakshyarawat1 commented 5 months ago

Operating System

Windows 11

Browser Version

Firefox

Firebase SDK Version

10.6.0

Firebase SDK Product:

Auth

Describe your project's tooling

I am using React (Vite) along with Nodejs at the backend.

Describe the problem

I have successfully created the createUserWithEmailAndPassword but when creating the functionality with signInWithPopUp along with GoogleProvider, I am facing an error saying "Firebase: Error (auth/argument-error)".

Steps and code to reproduce issue

Steps to reproduce the error.

import { browserPopupRedirectResolver, browserSessionPersistence, initializeAuth } from 'firebase/auth'
import { GoogleAuthProvider } from 'firebase/auth/cordova';
import { initializeApp } from 'firebase/app';

const firebaseConfig = {
  /* your config */
};

export const app = initializeApp(firebaseConfig);
export const provider = new GoogleAuthProvider();
export const auth = initializeAuth(app,{
  persistence: browserSessionPersistence,
  popupRedirectResolver: browserPopupRedirectResolver,
})

Here is the function created.

const handleGoogleLogin = async () => {
    signInWithPopup(auth, provider)
      .then((user) => {
        Swal.fire({
          title: "User Created !",
          text: "New user has been created ! ",
          icon: "success",
        });
        console.log(user);
      })
      .catch((err) => {
        Swal.fire({
          title: "Error !",
          text: err.message,
          icon: "error",
        });
        console.log(err.message);
      });
  };

Note: All exports and imports are perfect and not a reason for the error.

looptheloop88 commented 5 months ago

Hi @lakshyarawat1, I tried replicating the issue and I was able to. The GoogleAuthProvider imported from firebase/auth/cordova package being used in signInWithPopup is the one causing the argument error. The authentication flow or process will work as expected if you use GoogleAuthProvider from firebase/auth package.