Tim
Tim

Reputation: 2411

Firebase - Facebook Auth

I'm struggling to get my simple Facebook login to work. I'm simply trying to follow the example on the website but I run into this error:

Uncaught: L {code: "auth/argument-error", message: "signInWithPopup failed: First argument "authProvider" must be a valid Auth provider."}

And here is what I'm trying to do:

export const createUserWithFacebook = () => {
  let provider = firebase.auth.FacebookAuthProvider();
  firebaseApp.auth().signInWithPopup(provider).then(function(result) {
    // This gives you a Facebook Access Token. You can use it to access the Facebook API.
    var token = result.credential.accessToken;
    // The signed-in user info.
    var user = result.user;
    // firebaseApp.auth().signInWithRedirect(provider);
  }).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;
  });
}

Can anyone point out what I'm doing wrong here? Thanks for your help!

Upvotes: 1

Views: 453

Answers (1)

Cappittall
Cappittall

Reputation: 3441

At your firebase instance of the Facebook provider object should be:

let provider = new firebase.auth.FacebookAuthProvider();

this new will use firebase own constructor for the new instance.

instead of :

let provider = firebase.auth.FacebookAuthProvider();

here the link further details

Upvotes: 2

Related Questions