使用firebase进行Web身份验证 [英] Web Google authentication with firebase

查看:605
本文介绍了使用firebase进行Web身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


未捕获的异常:错误:运行此应用程序的
环境不支持此操作。 location.protocol必须
为http,https或chrome-extension,并且必须启用网络存储。

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:错误:运行此应用程序的
环境不支持此操作。 location.protocol必须
必须是HTTP,HTTPS或Chrome扩展程序,并且必须启用网络存储。

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.

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

Recently even i faced the same error.

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

You are opening this file directly in the browser without any web server. Firebase authentication won't work if you open the file directly. Try to load your HTML through web server it should solve your issue. The reason behind this bug is when you use authentication services they will use web storage. web storage does not work when you open an HTML file directly without any web browser

例如,使用apache并通过apache打开,如 http://localhost/filename.html

For example, use apache and open through apache like http://localhost/filename.html in the browser

这篇关于使用firebase进行Web身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆