Firebase google sign in pop up window flashes and never signing in using Vuejs?

Viewed 1650

I have used google sign in popup method in vuejs. In live google sign in pop up window flashes and never signed in. But everything works fine in local.

Here is firebase google sign in & sign up method code:

 const database = firebase.initializeApp(config);

 const firestore = database.firestore();

 var provider = new firebase.auth.GoogleAuthProvider();

 database.signIn = async (email, password) => {

   try {
   await firebase.auth().signInWithPopup(provider).then((result) => {
  // This gives you a Google Access Token. You can use it to access Google API.
  var token = result.credential.accessToken;
  // The signed-in user info.
  var user = result.user;

  console.log("user",user.displayName);
  console.log('result google',result.user);
  // ...
  store.commit("setCurrentUser", result.user);

   }).catch(function(error) {
        // Handle Errors here.
        var errorCode = error.code;
        var errorMessage = error.message;
        // The email of the user's account used.
        var email = error.email;
        // The firebase.auth.AuthCredential type that was used.
        var credential = error.credential;
        // ...
      });

      return true;
     } catch (error) {
      return error;
    }
  }

Tried by changing chrome pop up, cookies setting nothing works. Any help much appreciated please...

2 Answers

If it's working locally, you should make sure your hosting domain is registered with Google OAuth.

In Firebase console:

Develop -> Authentication -> Sign-in method -> Authorized domains

And add your domain to the list. It may take some time to verify.

If that doesn't work, try logging error.message for more information.

After updating firebase it works fine. npm i firebase@latest..

Related