gpt4 book ai didi

javascript - 使用 firebase 的网络谷歌身份验证

转载 作者:数据小太阳 更新时间:2023-10-29 05:21:26 24 4
gpt4 key购买 nike

uncaught exception: Error: This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.

var config = {
apiKey: "*****",
authDomain: "******",
};
firebase.initializeApp(config);
var provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('profile');
provider.addScope('https://www.googleapis.com/auth/drive');
firebase.auth().signInWithRedirect(provider);
alert(1);
}

最佳答案

uncaught exception: Error: This operation is not supported in the environment this application is running on. "location.protocol" must be HTTP, HTTPS or chrome-extension and web storage must be enabled.

最近我也遇到了同样的错误。

您直接在浏览器中打开此文件,无需任何网络服务器。如果直接打开文件,Firebase 身份验证将不起作用。尝试通过网络服务器加载您的 HTML 它应该可以解决您的问题。这个错误背后的原因是当你使用身份验证服务时,他们将使用网络存储。当您在没有任何网络浏览器的情况下直接打开 HTML 文件时,网络存储不起作用

比如使用apache,通过apache打开像http://localhost/filename.html在浏览器中

关于javascript - 使用 firebase 的网络谷歌身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44681352/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com