javascript - 传入的 JSON 对象不包含 client_email 字段
问题描述
我正在尝试创建一个 Firebase 云功能。所以我想在本地运行我的 firebase 云功能。但是如何设置身份验证不起作用。
我已经安装了 firebase 工具:https ://firebase.google.com/docs/functions/local-emulator
我已经运行了命令firebase login
,所以现在我已经登录了。然后我用本教程创建了我的 json 密钥:https ://cloud.google.com/docs/authentication/getting-started
现在如果我输入echo $GOOGLE_APPLICATION_CREDENTIALS
结果是/home/$USER/.google/****.json
包含
"project_id","private_key_id","private_key","client_email", "client_id", "auth_uri", "token_uri", "auth_provider_x509_cert_url", "client_x509_cert_url"
此外,我尝试安装完整的 google cloud sdk 并运行:gcloud auth application-default login
但没有成功。
Npm 包版本:
"firebase-functions":"3.0.2"
"firebase-admin": "8.2.0"
我想我已经提供了足够的信息,但如果您愿意,请随时问我。
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const express = require("express");
const app = express();
app.get("/", async (req, res) => {
admin.firestore().collection('something').get().then((collection) =>
return res.send({"count": collection.docs.length, "status": 200});
});
exports.exports = functions.https.onRequest(app);
代码并不重要,最重要的是即使我已经完成了所有这些步骤,当我在本地模拟我的firebasefirebase serve
并触发一个函数时,我有这个错误:错误:传入的JSON对象不包含client_email场地
我可以确保您的 json 文件包含 client_email 字段。
你能帮我通过谷歌进行身份验证吗?
谢谢你的帮助。
解决方案
我有一个类似的问题。这可能7.0.2
是firebase-tools
. 我回滚到版本7.0.0
,它现在可以工作了。
所以临时解决办法是:
npm i firebase-tools@7.0.0 -g
推荐阅读
- c++ - 使用 gtest 模拟 boost 共享内存派生类
- python - 如何在 tkinter 画布中嵌入 matplotlib 图形时获得(3d)交互性工作
- java - Spring Integration Tcp连接单用VS setSoKeepAlive
- javascript - Typescript 未正确编译为 commonjs/es2015
- python - 为 matplotlib 图自动创建新图形
- python - 调用 super().__init__ 时,如何判断超级初始化是否是 python3 中的 object.__init__?
- python - Python初学者问题:从字典中删除重复的应用程序 - 错误:列表索引超出范围
- daml - Daml Map 函数中 M.empty 的目的是什么?
- ruby-on-rails - 查询索引页面以过滤表中显示的结果 - RoR
- php - 我的登录功能只是重新加载我当前的页面而不是让我登录?Laravel 7与关闭冲突?