简体   繁体   中英

Firebase password auth not working

I am trying to build a login using the firebase email/password auth. I have set up my project and keys and everything works on the android side. I am trying to build the web side of it and can't seem to get the login to work.

Here is my javascript:

(function(){

// Initialize Firebase
  const config = {
    apiKey: "MY_API_KEY",
    authDomain: "MY_AUTH_DOMAIN",
    databaseURL: "MY_DATABASE_URL",
    storageBucket: "MY_STORAGE_BUCKET",
  };

firebase.initializeApp(config);

// Get elements
const loginEmail = document.getElementById('loginEmail');
const loginPassword = document.getElementById('loginPassword');
const loginButton = document.getElementById("loginButton");

// Add login event
loginButton.addEventListener('click', function() {
    // Get email and password
    const email = loginEmail.value;
    const pass = loginPassword.value;
    var auth = firebase.auth();

    // Sign in
    auth.signInWithEmailAndPassword(email, pass).catch(function(error) {
        // Handle Errors here.
        var errorCode = error.code;
        var errorMessage = error.message;
        console.log("Error code: " + errorCode);
        console.log("Error message: " + errorMessage);
    });
});


}());

Here are the errors I keep getting:

Error code: auth/internal-error
Error message: {"error":{"errors":[{"domain":"usageLimits","reason":"keyExpired","message":"Bad Request"}],"code":400,"message":"Bad Request"}}

I experienced same error and it is because I generated a new key from console.developers.google.com and still using the old Auto Generated API Keys (which was deleted). Got this resolved, when I re downloaded a new config file or replacing the old api key to the newly created/auto created key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM