与Firebase进行通信时Chrome扩展程序auth /网络请求失败 [英] Chrome Extension auth/network-request-failed when communicating with Firebase

查看:168
本文介绍了与Firebase进行通信时Chrome扩展程序auth /网络请求失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行 Firebase电子邮件登录进入我的扩展。从扩展popup.html,我打电话给我的login.html,处理过程,它看起来像这样:

$ p $ (错误){
var errorCode = error.code;
var errorMessage = =='auth / wrong-password'){
alert('Wrong password。');
} else {
console.error(error); //产生下面引用的错误
}
});

当我在本地打开我的login.html时,它可以正常工作。从扩展名弹出窗口调用它使它不工作,我得到错误:

lockquote
p>

我假定Chrome阻止我的脚本与服务器进行通信。有没有解决方法?在文档中找不到任何解决方案。这是不是内容安全政策,这是我已经修复。

----更新



Firebase现在发布了3.0.5之后,我收到了一个不同的错误:
$ b


auth / too-many-requests



解决方案

这个问题的解决方法应该在本周的下一个js版本3.0.5中。
还要确保你可能已经配置了你的manifest.json文件,使用下面的最小设置:
$ b $ pre $ content_security_policy :script-src'self'https://apis.google.com https://www.googleapis.com https://securetoken.googleapis.com; object-src'self',
权限:[https:// * / *,activeTab]


I'm trying to implement the Firebase E-Mail login into my Extension. From the extensions popup.html, I'm calling my login.html, which handles the process, it looks like this:

firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
          var errorCode = error.code;
          var errorMessage = error.message;
          if (errorCode === 'auth/wrong-password') {
            alert('Wrong password.');
          } else {
            console.error(error); //This produces the error quoted below
          }
        });

When I just open my login.html locally, it works. Calling it from the extensions popup makes it not work, and I get the error:

"auth/network-request-failed"

I'm assuming Chrome prevents my script from communication with the server. Is there a workaround for this? Couldn't find any solution in the docs. It is not the content security policy which does that, that I already fixed.

---- UPDATE

After Firebase now released 3.0.5, I'm getting a different error now:

"auth/too-many-requests"

解决方案

The fix for this issue should be out in the next js release 3.0.5 this week. Also make sure you have probably configured your manifest.json file, use the following minimum settings:

"content_security_policy": "script-src 'self' https://apis.google.com https://www.googleapis.com https://securetoken.googleapis.com; object-src 'self'", 
"permissions": ["https://*/*","activeTab"]

这篇关于与Firebase进行通信时Chrome扩展程序auth /网络请求失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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