javascript - Firebase 上的身份验证问题
问题描述
我在 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);
})
}
解决方案
推荐阅读
- java - Spring-Data-Jpa在持久化后清除链接实体的所有参数
- perl - 无法从 perl 中的命令行为标量赋值
- java - Spring Boot + Jackson:根据调用的 REST API 以不同的方式序列化对象
- mysql - 将 MySQL 查询转换为 Laravel
- c# - 如何从 C# 中的 SOAP 响应中提取数据
- permissions - 其他用户在 Google Cloud Platform 中的重复 IAM 权限
- css - 溢出-x 子元素宽度
- open-source - Prestashop 1.7.2 总额含税
- c# - 在数据库级别跟踪进程
- ansible - Ansible,with_item 循环问题