在我尝试使用“ firebase.auth()。createUserWithEmailAndPassword();”后,我收到“ xhrio.js:632 POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyCsoN9mw6k7qmqdw_-yejEd_tvjjtrqqfk 400”消息。
为什么?我该如何欺骗它?
我的index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="conatiner">
<input type="text" id="email" placeholder="email..."/>
<input type="text" id="password" placeholder="password..."/>
<button onclick="sing_In()">Sing In</button>
<button onclick="sing_Up()">Sing Up</button>
<button onclick="sing_Out()">Sing Out</button>
</div>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-auth.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyCsoN9mw6k7qmqdw_-yejEd_tvjjtrqqfk",
authDomain: "auth-1362e.firebaseapp.com",
databaseURL: "https://auth-1362e.firebaseio.com",
projectId: "auth-1362e",
storageBucket: "",
messagingSenderId: "765916790727",
appId: "1:765916790727:web:275006f41a04ad33"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
</script>
<script src="app.js"></script>
</body>
</html>
我的app.js:
function sing_Up(){
firebase.auth().createUserWithEmailAndPassword(document.getElementById("email").value, document.getElementById("password").value).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
}
function sing_In(){
firebase.auth().signInWithEmailAndPassword(document.getElementById("email").value, document.getElementById("password").value).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
}
function sign_Out(){
firebase.auth().signOut().then(function() {
// Sign-out successful.
}).catch(function(error) {
// An error happened.
});
}