小编Wil*_*ill的帖子

传入的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"
Run Code Online (Sandbox Code Playgroud)

我也尝试安装完整的google cloud sdk并运行:gcloud auth application-default login但是没有成功。

Npm软件包版本:

"firebase-functions":"3.0.2"
"firebase-admin": "8.2.0"
Run Code Online (Sandbox Code Playgroud)

我想我已经提供了足够的信息,但是如果您愿意,可以随时问我更多。

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);
Run Code Online (Sandbox Code Playgroud)

代码并不重要,最重要的是,即使我已经完成了所有这些步骤,当我在本地模拟Firebase firebase serve并触发函数时,却出现此错误:错误:传入的JSON对象不包含client_email领域

我可以确保您的json文件包含client_email字段。

您可以帮我与Google进行身份验证吗?

谢谢你的帮助。

javascript firebase google-cloud-functions firebase-admin google-auth-library

21
推荐指数
3
解决办法
2717
查看次数

使用 0.0.0.0 主机时 Firebase 模拟器速度缓慢

我\xe2\x80\x99m 在使用 Apple Silicon(M1 芯片)的 Mac Mini 上设置 Firebase 模拟器时遇到问题。

\n

我发送到 Firestore(使用模拟器)的每个请求都需要很长时间才能完成(有时它永远不会完成,并且我收到网络错误,指出无法到达后端\xe2\x80\x99t):

\n
\n

@firebase/firestore:Firestore (8.2.5):无法到达 Cloud Firestore 后端。后端在 10 秒内未响应。\n这通常表明您的设备当前没有正常的 Internet 连接。客户端将以离线模式运行,直到能够成功连接到后端。

\n
\n

事实证明这种情况发生是因为我在文件中设置host了。如果我删除主机字段或将其设置为,那么我不会遇到任何问题。0.0.0.0firebase.jsonlocalhost

\n

这是我的firebase.json文件:

\n
{\n  "firestore": {\n    "rules": "./firestore.rules"\n  },\n  "emulators": {\n    "firestore": {\n      "host": "0.0.0.0",\n      "port": 8080\n    }\n  }\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n

我将其设置为的原因0.0.0.0是因为我需要在不同的计算机(即平板电脑)上测试我的应用程序,而我们设法使其工作的唯一方法是将主机设置为,0.0.0.0因为该主机将解析所有地址与我们的机器相关。这样,我就可以使用我的本地 IP 地址(即192.168.0.1)访问模拟器。

\n

我注意到这个问题只发生在配备 M1 Apple Silicon 芯片的新 Mac 上。所以我想知道这是否与M1解析IP地址的方式有关。

\n

有任何想法吗?

\n

macos networking firebase-tools google-cloud-firestore

5
推荐指数
1
解决办法
1305
查看次数