I am trying to set up push notifications using Google Calendar. I am currently using oAuth playground to understand how this works. So I selected Calendar API v3, authorized it, used the authorization code and access to the token, and requested the following URI: https://www.googleapis.com/calendar/v3/calendars/ tl7grdo4gqdqj4gtanpioksi6k@group.calendar.google.com / events / watch . The request contains the following body:
{
"id": "154345345-345345345",
"type": "web_hook",
"address": "https://www.somedomain.com/web_hook.php"
}
I added the domain to the webmaster tools to verify ownership, and also added it to the list of allowed domains in the console.
Sending the following request:
POST /calendar/v3/calendars/tl7grdo4gqdqj4gtanpioksi6k@group.calendar.google.com/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"
}
Gives the following answer:
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"
}
]
}
}
, , , . .