3

How can I setup a webhook for the google calendar api?

I'm currently making a post to the api, stating the webhook/ address 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"
    }
})

However, I get the error:

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

How can I verify the domain of my cloud function?

I have tried this method but still get the 401:

How to perform domain verification for Firebase functions

Bomber
  • 10,195
  • 24
  • 90
  • 167
  • Great question, I'm struggling with the same thing. Trying to watch events to trigger cloud functions. – K-Dawg Mar 28 '19 at 20:47
  • I think I might have a possible solution. I'm going to try setting a CNAME on my domain. So that I can redirect traffic back to the cloud function via my registered domain using a subdomain. This way I can still use my domain for my VPS and for cloud functions too. If I have any luck with this i will update you. – K-Dawg Mar 28 '19 at 21:45
  • Try this https://stackoverflow.com/questions/49661425/how-to-perform-domain-verification-for-firebase-functions – Bomber Mar 29 '19 at 11:01
  • 1
    By the way I tried the CNAME option. It doesn't work (Google disallow CNAMES to cloud functions) it just returns a 404. You need to verify your domain and point it to Google Servers. I wanted to also serve a wordpress site from the same domain so this wasn't right for me. In the end I decided to just use NodeJS and host it myself. – K-Dawg Apr 01 '19 at 16:08

0 Answers0