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

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

问题描述

未捕获的异常:错误:此操作在此应用程序运行的环境.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.

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);
}

推荐答案

未捕获的异常:错误:此操作在此应用程序运行的环境.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.

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

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 Google 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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