Firebase GAS webapp Google弹出消失 [英] Firebase GAS webapp Google popup disappears
问题描述
<发生了什么,是弹出来,立即消失。任何人都可以看到我在这里做错了吗?
感谢您的帮助。
< html lang =en>
< head>
< script src =https://www.gstatic.com/firebasejs/3.1.0/firebase-app.js>< / script>
< script src =https://www.gstatic.com/firebasejs/3.1.0/firebase-auth.js>< / script>
< script src =https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js>< / script>
< script>
var config = {
apiKey:,
authDomain:,
databaseURL:,
storageBucket:
};
firebase.initializeApp(config);
< / script>
< / head>
< body>
< label id =name>名字< / label>
< script>
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth()。signInWithPopup(provider).then(function(result){
var user = result.user; $ b $ document.getElementById(name)。value = user; catch(function(error){
console.log(error);
});
< / script>
< / body>
< / html>
问题解决了。我接触到了Firebase的精彩人物,而我和丹麦人一直在努力。我的代码很好,问题在于证书。如果您遇到同样的问题,那么我们的所有步骤都是:
Google配置
- 转到此链接 Google开发者控制台
- 转至屏幕左侧的凭证选项
- 点击浏览器API密钥并将其复制
- 确保您复制的API密钥与您的网络应用程序配置中的API密钥相同。如果不匹配,请将代码中的api键替换为您复制的API键
- 在OAuth 2.0客户端ID下,单击Web客户端(由Google服务自动创建)'
- 导航到授权的JavaScript来源部分
添加您在测试页面时访问的完整网址或者可以肯定的是,这是一个更普遍的,比如 https://script.google.com/* 点击oAuth网络应用程序
- 对于授权的JavaScript来源,请添加.firebaseapp.com / li>
对于授权的重定向URI,请添加.firebaseapp.com / __ / auth / handler
- 复制客户端ID和客户端密钥 Firebase控制台
- 点击Google
- 点击Web SDK配置
- 更新客户端ID和使用您获得的值的秘密
- 点击保存
Firebase配置转到此Firebase控制台 如果没有,请点击添加域名,输入您的自定义域名并点击添加 I am trying to upgrade my firebase GAS webapp, and previously I had a popup which would log the user in with Google. I'm not sure what I'm doing wrong, but I have upgraded to the new firebase, and am now trying to get the same login working with the new code format. What is happening, is that the popup comes up and immediately disappears. Can anyone see what I am doing wrong here? Thanks for you help.
The problem is solved. I got onto the wonderful people at Firebase, and Dane and I worked through it all till it worked. My code was fine, the issue was in the credentials. If you have the same issue, are all the steps we went through: Google Configuration Add the full URL you're accessing when you're testing the page, or to be sure, a more general one like https://script.google.com/* Click on the oAuth web application For authorized redirect URIs please add .firebaseapp.com/__/auth/handler Click 'Web client (auto created by Google Service)' Firebase Configuration If not, click Add domain, input your custom domain and click Add Open Google Chrome and go to the page where your app is deployed. 这篇关于Firebase GAS webapp Google弹出消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
选择您的项目,单击身份验证选项,然后选择屏幕顶部的登录方法
<html lang="en">
<head>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>
<script>
var config = {
apiKey: "",
authDomain: "",
databaseURL: "",
storageBucket: ""
};
firebase.initializeApp(config);
</script>
</head>
<body>
<label id="name">First Name</label>
<script>
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result) {
var user = result.user;
document.getElementById("name").value = user;
}).catch(function(error) {
console.log(error);
});
</script>
</body>
</html>