首页 > 解决方案 > 什么原因无法加载默认凭据错误?

问题描述

我正在关注教程。

我部署了这个云功能firebase serve

exports.createScream = functions.https.onRequest((req, res) => {
    const newScream = {
        body: req.body.body,
        userHandle: req.body.userHandle,
        createdAt: admin.firestore.Timestamp.fromDate(new Date())
    };

    admin
        .firestore()
        .collection('screams')
        .add(newScream)
        .then((doc) => {
            res.json({ message: `document ${doc.id} created sucseccfully` });
        })
        .catch((err) => {
            res.status(500).json({ error: err });
            console.error(err);
        });
});

我收到此错误:

functions: Beginning execution of "createScream"
  Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
      at GoogleAuth.getApplicationDefaultAsync (C:\Users\Örs\Desktop\social-app\screem-app_functions\functions\node_modules\google-auth-library\build\src\auth\googleauth.js:161:19)
     at process._tickCallback (internal/process/next_tick.js:68:7)
i  functions: Finished "createScream" in ~1s

我搞砸了什么?我如何解决它?谢谢你的时间。

标签: javascriptfirebasegoogle-cloud-firestore

解决方案


推荐阅读