Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Calendar "Unauthorized WebHook callback channel" error

I'm trying to set-up push notifications with Google Calendar. Currently I'm using the oAuth playground to get a feel for how it works. So I've selected Calendar API v3, authorised it, used the authorisation code and access token provided and querying the following URI: https://www.googleapis.com/calendar/v3/calendars/[email protected]/events/watch. The request contains the following body:

{ "id": "154345345-345345345", "type": "web_hook", "address": "https://www.somedomain.com/web_hook.php" }

I have added the domain to webmaster tools to prove ownership and also added it to the "allowed domains" list within the developers console.

Sending the following request:

POST /calendar/v3/calendars/[email protected]/events/watch HTTP/1.1 Host: www.googleapis.com Content-length: 105 Content-type: application/json Authorization: Bearer <some access token> { "id": "154345345-345345345", "type": "web_hook", "address": "https://www.somedomain.com/web_hook.php" }

Produces the following response:

HTTP/1.1 401 Unauthorized Content-length: 318 X-xss-protection: 1; mode=block X-content-type-options: nosniff Expires: Tue, 09 Sep 2014 13:22:51 GMT Server: GSE Cache-control: private, max-age=0 Date: Tue, 09 Sep 2014 13:22:51 GMT X-frame-options: SAMEORIGIN Content-type: application/json; charset=UTF-8 Www-authenticate: Bearer realm="https://accounts.google.com/AuthSubRequest", error=invalid_token { "error": { "code": 401, "message": "Unauthorized WebHook callback channel: https://www.somedomain.com/web_hook.php", "errors": [ { "domain": "global", "message": "Unauthorized WebHook callback channel: https://www.somedomain.com/web_hook.php", "reason": "push.webhookUrlUnauthorized" } ] } }

I'm hoping to get some very basic but specific steps I need to follow to get this functioning correctly. Thanks for any help.

like image 719
Bower Avatar asked Mar 19 '23 12:03

Bower


1 Answers

Evidently the oAuth playground simply doesn't have a handle on the domains added via the developers console in order to verify the provided webhook has been authorised. I managed to get it working with code which seemed to the follow the same steps as the playground.

like image 195
Bower Avatar answered Apr 25 '23 18:04

Bower