我在我的终端中得到了这个错误:
@firebase/database: FIREBASE WARNING: {"code":"app/invalid-
credential","message":"Credential implementation provided to .
initializeApp() via the \"credential\" property failed to fetch a valid
Google OAuth2 access token with the following error: \"Failed to parse
access token response: Error: Error while making request: getaddrinfo
ENOTFOUND metadata.google.internal metadata.google.internal:80. Error
code: ENOTFOUND\"."}`使用firebase-tools时。这是我试图运行的简单节点脚本。
const admin = require("firebase-admin");
const firebase = admin.initializeApp({
apiKey: "MY_API_KEY",
authDomain: "APP_ID.firebaseapp.com",
databaseURL: `https://DATABASE_URL.firebaseio.com`,
projectId: "APP_ID"
});
const snap = firebase
.database()
.ref("REF")
.child("ID")
.once("value");
console.log(snap);Firebase工具版本: 5.0.1
我尝试过卸载和重新安装,使用firebase login / firebase-logout登录和注销firebase-tools
发布于 2018-10-09 22:42:12
配置结构错误,缺少字段...
admin.initializeApp({
databaseURL: 'https://<DATABASE_NAME>.firebaseio.com',
credential: admin.credential.cert({
projectId: '<PROJECT_ID>',
clientEmail: 'foo@<PROJECT_ID>.iam.gserviceaccount.com',
privateKey: '-----BEGIN PRIVATE KEY-----\n<KEY>\n-----END PRIVATE KEY-----\n'
})
});您不能只使用"web“配置来访问Firebase Admin SDK。
因为如果这是可能的,那么私钥就会向公众公开。
请参阅documentation。
发布于 2020-07-23 03:53:42
我通过运行以下命令简单地解决了这个问题:
firebase login当我没有互联网连接时,我也有这个错误。
https://stackoverflow.com/questions/52723471
复制相似问题