我在Firebase的网页上为Google添加了一种登录方法,并获得了重定向以成功登录Google。问题是,登录后,我在Firebase的“身份验证”部分中看不到任何用户。请帮助。我对此已经坚持了很长时间。 这是HTML文件:
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<button type="button" id="googlebtn" onclick="GoogleLogin();">Google</button>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.6.2/firebase.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.6.2/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyA4SJ-R5AK6YUd4Z1hXXQBH-UGb0pLi8ug",
authDomain: "oshop-c2ca6.firebaseapp.com",
databaseURL: "https://oshop-c2ca6.firebaseio.com",
projectId: "oshop-c2ca6",
storageBucket: "oshop-c2ca6.appspot.com",
messagingSenderId: "1089602124550",
appId: "1:1089602124550:web:4607bbd77cffa950eebc87",
measurementId: "G-64Z9HFJD92"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
<script src="google.js" type="text/javascript"></script>
</body>
</html>
google.js 文件:
function GoogleLogin(){
var provider=new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithRedirect(provider).then(function(){
window.location="index.html";
}).catch(function(error){
var errorMessage=error.message;
alert(errorMessage);
})
}