使用新的 firebase 版本,您需要在我的 firebase 应用程序中通过 node.js 访问。
var firebase = require("firebase");
var parms={.......}
firebase.initializeApp(parms);
var token = firebase.auth().createCustomToken('123'); //Token generated successfully
//Line below throws error
firebase.auth().signInWithCustomToken(token).catch(function(error) {
//do something
});
如果我在浏览器中使用来自 javascript 的 signInWithCustomToken,它工作正常。但是如果我从命令行使用它:node file.js,它会抛出错误:firebase.auth().signInWithCustomToken(token) generate "Object has no method 'signInWithCustomToken '"错误
为什么?
请您参考如下方法:
在这部分,web 和节点 api 是不同的。
如升级指南中所述 (https://firebase.google.com/support/guides/firebase-web#update_your_authentication_code_numbered) 您需要为 node.js 应用程序使用服务帐户。这个页面是一个很好的起点:https://firebase.google.com/docs/database/server/start#section-account
我很乐意将指向 auth api 页面的链接粘贴给您,但我只能发布 2 个链接。 :)