firebase - 使用 firebase-functions-test 运行离线测试时缺少 `client_secret`

标签 firebase google-cloud-firestore google-cloud-functions

我正在使用 firebase-functions-test对我的云功能进行单元测试。测试配置为运行离线测试,但在访问测试 firestore 时,我仍然收到身份验证错误:无法解析刷新 token 文件:错误:刷新 token 必须包含“client_secret”属性。。什么会导致这种情况?

最佳答案

深入挖掘firebase-functions-testfirebase-admin的代码后,在为离线模式初始化firebase-functions-test时, 它仍然使用 gcloud application default credentials .如果您曾经安装和使用过 gcloud,它位于 ~/.config/gcloud/application_default_credentials.json 中。

我在 GCP 上的一个旧项目中有一个设置,该项目是作为服务帐户而不是经过身份验证的用户登录的,因此我有默认的凭据设置,但它不包含所需的 client_secret通过 firebase-admin。我只是使用 gcloud auth application-default login 登录应用程序默认值。这解决了问题。

仍然对离线 模式需要身份验证这一事实感到困惑。我没有使用无效但格式正确的应用程序默认凭据进行测试。

关于firebase - 使用 firebase-functions-test 运行离线测试时缺少 `client_secret`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53181510/

相关文章:

ios - 此处可能误用逗号运算符

javascript - VueJS - 变量已定义但从未使用过(将数据发送到 Firebase)

firebase_messaging 如何清除通知?

typescript - Firebase Cloud Functions Firestore 触发器产生 : Error: 7 PERMISSION_DENIED: Missing or insufficient permissions

firebase - 文档流 snapshot.hasData 返回 true 但没有数据,如何解决?

firebase - flutter 包 flutter_stripe 是否需要后端来处理付款?

javascript - 如何从客户端使用 firestore 模拟器

firebase - "firebase serve --only functions"不起作用

windows - Win32/64 应用程序是否可以从 Firebase 接收推送通知消息?

firebase - 使用 Firestore Cloud Functions 进行计数