Javascript Chrome扩展弹出窗口中的Firebase身份验证

Javascript Chrome扩展弹出窗口中的Firebase身份验证,javascript,google-chrome-extension,firebase,firebase-authentication,Javascript,Google Chrome Extension,Firebase,Firebase Authentication,我正在尝试在Chrome扩展中使用身份验证(电子邮件/密码)。如果我将身份验证代码放在后台脚本中,我似乎工作得很好。但是,我似乎无法将其作为浏览器操作脚本使用 我使用以下代码作为扩展的基础: 我将浏览器_action.js更改为: Firebase.enableLogging(true); var f = new Firebase('https://myapp.firebaseio.com/'); f.authWithPassword({ email : "a@b.cd"

我正在尝试在Chrome扩展中使用身份验证(电子邮件/密码)。如果我将身份验证代码放在后台脚本中,我似乎工作得很好。但是,我似乎无法将其作为浏览器操作脚本使用

我使用以下代码作为扩展的基础:

我将浏览器_action.js更改为:

Firebase.enableLogging(true);
var f = new Firebase('https://myapp.firebaseio.com/');

f.authWithPassword({    
    email    : "a@b.cd",
    password : "1234"
}, function(error, authData) {
    if (error) {
        alert("Login Failed!", error);
} else {
    alert("Authenticated successfully with payload:", authData);
}
});
我还保持了现有浏览器_action.html的不变:

<!doctype html>


<style type="text/css">
    #mainPopup {
        padding: 10px;
        height: 200px;
        width: 400px;
        font-family: Helvetica, Ubuntu, Arial, sans-serif;
    }
    h1 {
        font-size: 2em;
    }
</style>

<div id="mainPopup">
<h1>Firebase test!</h1>
<p>Clicks: <span id="contents"></span></p>
</div>

<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase.js"></script>
<script src="browser_action.js"></script>
如果我将firebase代码和身份验证代码移动到background.js文件中,它会工作,并向我发出警报,表示它已成功通过身份验证


我做错了什么?为什么不可能呢?

示例chrome扩展已经三年没有更新了,所以它的Firebase版本已经过时了。替换
https://cdn.firebase.com/v0/firebase.js
https://cdn.firebase.com/js/client/2.2.1/firebase.js
browser\u action.html
中,您应该能够成功使用
authWithPassword

对于自2016年7月以来遇到此问题的任何人,Firebase提供了一套关于如何为Chrome扩展设置auth的更新说明(在他们的示例中,他们使用Google auth)。在看到这篇文章之前,我经历了很多困难,希望能节省一些时间

我是个白痴:’)。。。我假设v0意味着它将始终获得库的最新版本。我错了,问题是,代码示例也过时了:在自述文件中,作者引用了Firebase控制台中不再存在的UI元素:外部项目的白名单客户端ID(可选)。
Uncaught TypeError: f.authWithPassword is not a function