网站谷歌认证与火力
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.
最近连我面临着同样的错误。
您正在浏览器中直接打开此文件,而无需使用任何webserver。如果您直接打开文件,Firebase身份验证工作。尝试通过网络服务器加载你的html,它应该可以解决你的问题。 此错误背后的原因是当您使用身份验证服务时,他们将使用Web存储。网络存储不工作的时候,你直接打开一个html文件,而无需任何网络浏览器
例如使用使用Apache和通过Apache一样http://localhost/filename.html在浏览器中打开
感谢您的答复。是的,这是真的。我在adobe cep扩展中使用该代码,它没有任何网页浏览器。所以有可能没有网络服务器或网络浏览器运行该代码 – ArunKarthick
否验证将无法在没有网络服务器工作 –
好吧是任何想法的土坯扩展包含任何网络服务器 – ArunKarthick
试试这个代码。它应该工作。
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);
//add the code below to your previous lines
firebase.auth().getRedirectResult().then(function(authData) {
console.log(authData);
}).catch(function(error) {
console.log(error);
});
感谢您的回复。对不起,代码没有解决我的问题 – ArunKarthick
看起来像HTTP问题,推动SDK需要你authdomain是HTTPS :// –
这里你的实际问题是什么?代码仅在本地主机上运行的 – jeffbyrnes
。是否有可能在没有任何网页浏览器的情况下运行该代码 – ArunKarthick