简体   繁体   English

Firebase密码验证无效

[英]Firebase password auth not working

I am trying to build a login using the firebase email/password auth. 我正在尝试使用firebase email / password auth构建登录。 I have set up my project and keys and everything works on the android side. 我已经设置了我的项目和键,一切都在android方面工作。 I am trying to build the web side of it and can't seem to get the login to work. 我正在尝试构建它的Web端,似乎无法使登录工作。

Here is my javascript: 这是我的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). 我遇到了同样的错误,因为我从console.developers.google.com生成了一个新密钥,并且仍在使用旧的自动生成的API密钥(已删除)。 Got this resolved, when I re downloaded a new config file or replacing the old api key to the newly created/auto created key. 当我重新下载新的配置文件或将旧的api密钥替换为新创建的/自动创建的密钥时,解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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