我继承了一个使用 Firebase 进行通知的客户端项目,并且我正在尝试找出管理员用户是谁(以便我可以获得 Firebase 项目的邀请)。
我拥有的只是我在客户端 AWS 上找到的以下 JSON 格式的 Firebase 证书(“...”= 已编辑):
{
"type": "service_account",
"project_id": "...",
"private_key_id": "...",
"private_key": "...",
"client_email": "[email protected]",
"client_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "..."
}
我想我可以使用 firebase-admin 来获取所有用户的列表:
const admin = require('firebase-admin')
admin.initializeApp({
databaseURL: 'https://<project-id>.firebaseio.com',
credential: admin.credential.cert(require('./firebase.json')),
})
;(async () => {
console.log(await admin.auth().listUsers(100))
})()
但是这样做我收到以下错误:
(node:77972) UnhandledPromiseRejectionWarning: Error: There is no configuration corresponding to the provided identifier.
at FirebaseAuthError.FirebaseError [as constructor] (.../firebase-test/node_modules/firebase-admin/lib/utils/error.js:44:28)
at FirebaseAuthError.PrefixedFirebaseError [as constructor] (.../firebase-test/node_modules/firebase-admin/lib/utils/error.js:90:28)
at new FirebaseAuthError (.../firebase-test/node_modules/firebase-admin/lib/utils/error.js:149:16)
at Function.FirebaseAuthError.fromServerError (.../firebase-test/node_modules/firebase-admin/lib/utils/error.js:188:16)
at .../firebase-test/node_modules/firebase-admin/lib/auth/auth-api-request.js:1665:49
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async .../firebase-test/firebase.js:10:14
这个错误是什么意思?凭证 JSON 是否不正确? AWS 上似乎正在使用它来发送通知。
还有其他想法如何从上面的 JSON 中获取登录电子邮件吗?
感谢您的帮助!
遇到同样的问题;问题是需要在 firebase 中启用“身份验证”。
登录 Firebase 并单击“所有产品”,单击“身份验证”并进行连接。