首页 > 解决方案 > 验证 webhook 的云功能域

问题描述

如何为google calendar api设置 webhook ?

我目前正在向 api 发帖,说明 webhook/ 地址https://us-central1-pushmessage-bd1eb.cloudfunctions.net/getUsers

axios({
    method: "POST",
    url:
        "https://www.googleapis.com/calendar/v3/calendars/xxx/events/watch",
    headers: {
        "Access-Control-Allow-Origin": "*",
        "Content-Type": "application/json;charset=UTF-8",
        Authorization: token.token_type + " " + token.access_token,
        "Content-Type": "application/json"
    },
    data: {
        id: "tester",
        type: "web_hook",
        address: "https://xxx.cloudfunctions.net/getUsers"
    }
})

但是,我收到错误:

  code: 401,
  message: 'Unauthorized WebHook callback channel: https://us-central1-xxx.cloudfunctions.net/getUsers' }

如何验证我的云功能的域?

我已经尝试过这种方法,但仍然得到 401:

如何为 Firebase 函数执行域验证

标签: firebasegoogle-cloud-functionsgoogle-calendar-api

解决方案


推荐阅读