【问题标题】:Slack API: How to authenticate with oAuth?Slack API:如何使用 oAuth 进行身份验证?
【发布时间】:2021-01-14 22:42:04
【问题描述】:

我关注Slack's docs on authenticating with oAuth.

范围和令牌设置得很好。我正在努力设置installationStore.

这是我用来从 Firestore 数据库中获取数据的代码:

  installationStore: {
    fetchInstallation: async InstallQuery => {
      // change the line below so it fetches from your database
      // return await database.get(InstallQuery.teamId);

  let cityRef = db.collection("teams").doc(InstallQuery.teamId);
  let getDoc = cityRef
    .get()
    .then(doc => {
      if (!doc.exists) {
        console.log("No such document!");
      } else {
        console.log("Document data:", doc.data());
      }
    })
    .catch(err => {
      console.log("Error getting document", err);
    });

  return await getDoc;
}
}

我不确定我应该返回等待的是 getDoc,还是不是。有什么线索吗?

【问题讨论】:

    标签: javascript google-cloud-firestore oauth slack-api


    【解决方案1】:

    试试这样的:

    installationStore: {
      fetchInstallation: async (InstallQuery) => {
        return await getData();
      };
    }
    
    async function getData() {
      try {
        let cityRef = db.collection("teams").doc(InstallQuery.teamId);
        let doc = await cityRef.get();
        return doc.data();
      } catch(ex){
          throw new Error("Failed fetching installation");
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-27
      • 2013-11-29
      • 2020-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-10
      • 2011-10-20
      相关资源
      最近更新 更多