igarcia igarcia - 29 days ago 28x
AngularJS Question

Why do I see a "400 (Bad Request)" in my developer console when sign-in to Firebase Authentication fails?

I'm using the method signInWithEmailAndPassword to validate a user in my angular based application, I wrote this code:

firebase.auth().signInWithEmailAndPassword(email, password).then(
function(authData) {
//user was validated
function(error) {
// Handle Errors
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
} else {

When I run this code with a valid user and password it works well, no errors in the console, but when I set an invalid user it throws a Bad Request in the console, and then it returns the corresponding error which is user inexistent. So it seems the validation is working fine but I wonder what this bad request means or what I'm missing in the code. This is the bad request message

POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=AIzaSyDDCVDWgy9LGYLWmMPQjPZ49RbDkWjWVTk 400 (Bad Request) firebase.js:107

Thanks in advance


This HTTP request is how Firebase Authentication verifies the user credentials. The SDK/client then turns it into the error with an errorCode and errorMessage that you handle.

You can see that if you look in the body of the response:

 "error": {
  "errors": [
    "domain": "global",
    "reason": "invalid",
    "message": "EMAIL_NOT_FOUND"
  "code": 400,
  "message": "EMAIL_NOT_FOUND"