Firebase 管理员身份验证令牌已撤销

Firebase Admin Auth Token Revoked

我正在尝试实现一个 node.js 服务器来监听我的 firebase 数据库中的变化。这是我初始化服务器的代码:

var admin = require('firebase-admin');
var serviceAccount = require('./SERVICE-ACCOUNT.json');

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://APP-NAME.firebaseio.com"
});

var db = admin.database();
admin.database.enableLogging(true);
var convRef = db.ref('conversations');
convRef.once('value', function(snapshot) {
  console.log("VALUE: " + snapshot.val());
}, function(error) {
  console.log("ERROR: " + error.code);
});

启用调试后,我收到错误:

p:0: Listen called for /conversations default  
p:0: Making a connection attempt  
p:0: Auth token refreshed  
getToken() completed. Creating connection. 
c:0:0: Connection created  
c:0:0:0 Websocket connecting to wss://APP-NAME.firebaseio.com/.ws?v=5  
c:0:0:0 Websocket connected.  
c:0:0: Reset packet received.  New host: s-usc1c-nss-123.firebaseio.com  
c:0:0: Shutting down all connections  
c:0:0:0 WebSocket is being closed  
c:0:0:0 Websocket connection was disconnected.  
c:0:0:1 Websocket connecting to wss://s-usc1c-nss-123.firebaseio.com/.ws?v=5&ns=APP-NAME 
c:0:0:1 Websocket connected.  
c:0:0: Realtime connection established.  
p:0: connection ready  
p:0: reportStats {"c":{"sdk.js.4-0-4":1}}  
p:0: {"r":1,"a":"s","b":{"c":{"sdk.js.4-0-4":1}}}  
p:0: {"r":2,"a":"gauth","b":{"cred":"REDACTED"}}  
p:0: Listen on /conversations for default  
p:0: {"r":3,"a":"q","b":{"p":"/conversations","h":""}}  
p:0: from server: {"r":1,"b":{"s":"ok","d":""}}  
c:0:0: Primary connection is healthy.  
p:0: from server: {"r":2,"b":{"s":"permission_denied","d":"Access denied."}}  
Auth token revoked: permission_denied/Access denied.

我意识到我在错误的地方创建了我的服务帐户。由于我不是该项目的所有者,因此它无效。我让项目的所有者为我创建了一个服务帐户,现在一切正常。