Calender Push notification does not work.

3,656 views
Skip to first unread message

Chintan Prajapati

unread,
Oct 17, 2013, 9:29:54 AM10/17/13
to google-ca...@googlegroups.com
I am trying to watch events resource based on given example using API explorer and Chrome Advanced Rest Client.

Requst

POST https://www.googleapis.com/calendar/v3/calendars/XXX%40gmail.com/events/watch?key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.AHES6ZSNBYiHYPu6Y1_5P08hdb-EX5pdF4Ygj5ou_RKp_jOCS5beiDDH
X-JavaScript-User-Agent:  Google APIs Explorer
{
"id": "01234567-89ab-cdef-0123456789ab",
"type": "web_hook",
"token": "token=123546"
}


Response

401 Unauthorized

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  188
content-type:  application/json; charset=UTF-8
date:  Thu, 17 Oct 2013 12:49:00 GMT
expires:  Thu, 17 Oct 2013 12:49:00 GMT
server:  GSE
www-authenticate:  Bearer realm="https://www.google.com/accounts/AuthSubRequest", error=invalid_token
{
"error": {
"errors": [
{
"domain": "global",
"reason": "push.webhookUrlUnauthorized",
"message": "Unauthorized WebHook callback channel: https://www.example.com/WebHook/Index"
}
],
"code": 401,
"message": "Unauthorized WebHook callback channel: https://www.example.com/WebHook/Index"
}
}



I have already whitelisted my domain www.example.com

I googled about this issue , but could not find much help.

can anybody guide, whats wrong with request ?

venkatesh bachu

unread,
Oct 26, 2013, 6:08:06 AM10/26/13
to google-ca...@googlegroups.com

when you try with API Explorer,it will not use your OAuth2.0 project keys where you have registerd whitelisted domains, maybe it would use another keys

try to use client/lib

Markus Welter

unread,
Nov 23, 2013, 9:12:34 PM11/23/13
to google-ca...@googlegroups.com
Hi,

I have the exact same problem!

It would be logical that if I provide {YOUR_API_KEY} with the API KEY from google API Console and the bearer of the calendar that it should work.
But as soon as I use the API KEY I always get a "Invalid Credentials" error

No resources found, as well...

Thanks,

Markus

dinesh reddy

unread,
Dec 11, 2013, 4:29:50 AM12/11/13
to google-ca...@googlegroups.com
I am seeing the same issue, can anyone of you got this working ? please help

Chintan Prajapati

unread,
Apr 8, 2014, 9:58:18 AM4/8/14
to google-ca...@googlegroups.com

Finally It worked for me , cause of error "Unauthorized WebHook callback channel" was in Configuration of Project in

  • Go to Google Developers Console.
  • Click your project name
  • Click "API & Auth" Menu on left
  • then click on sub menu "Push"
  • Click on Add Domains button which Allows webhook notifications to be sent to the entered domains

Happy coding :)

jeffrey...@myshowing.co

unread,
May 20, 2014, 6:05:09 PM5/20/14
to google-ca...@googlegroups.com
I had this same issue but still can't seem to get it to work.

I add my domain (https://www.myshowing.co) through Webmaster Tools. I then whitelisted my domain (www.myshowing.co) under "Push" in the Google Developers Console.

Does anybody have a suggestion for the next step in debugging?

Chintan Prajapati

unread,
May 21, 2014, 3:07:03 AM5/21/14
to google-ca...@googlegroups.com
Hi Jeff, 

Did you try adding  https://www.myshowing.co within javascript origin ,anad redirect URI section (from Api & Auth -> Credentials)? 






















Hope it helps.

jeffrey...@myshowing.co

unread,
May 22, 2014, 1:25:01 AM5/22/14
to google-ca...@googlegroups.com
Hi Chintan,

Thank you so much for responding to my question. I hadn't added https://www.myshowing.co as an either an authorized Javascript origin nor as an authorized redirect URI. After doing so I went back to API Explorer, authorized through OAuth, and then made the request.

I am now noticing that I am receiving

www-authenticate:  Bearer realm="https://accounts.google.com/AuthSubRequest", error=invalid_token

in the header. It's my guess that the API explorer is not taking my OAuth credentials for the test API call. This doesn't make sense to me so I am now going to try and setup a "watch" call through the python API client.

http = httplib2.Http()
body = {
    'id': '123456',
    'type': 'web_hook',
}
self.service.events().watch(calendarId='"MY_EMAIL', body=body).execute(http=http)

Doubtful, but I'm hoping that the API Explorer client is broken.

Again, thank you so much.

Jeff

Lukáš Voborský

unread,
May 29, 2014, 3:52:24 AM5/29/14
to google-ca...@googlegroups.com
Hello, I'm facing similar problem. I use service account which works perfectly for all other drive operations except drive changes watch. 

Below is application code which now fails with "Unauthorized WebHook callback channel" exception. I also dumped requests and responses which are generated when drive.changes.watch.execute is called.

Target notification address is whitelisted in APIs & auth Push control panel (I even listed it in Javascript origins and referrers) and now I'm stuck with this 401 Unauthorized error.

Does someone know where I'm making mistake? Thanks for any help. 


PrivateKey serviceAccountPrivateKey = SecurityUtils.loadPrivateKeyFromKeyStore(SecurityUtils.getPkcs12KeyStore(), p12File, "notasecret", "privatekey", "notasecret");
JsonFactory jsonFactory = new JacksonFactory();
HttpTransport t = GoogleNetHttpTransport.newTrustedTransport();
GoogleCredential gc = new GoogleCredential.Builder()
.setTransport(t)
.setJsonFactory(jsonFactory)
.setServiceAccountScopes(Collections.singleton(DriveScopes.DRIVE))
.setServiceAccountPrivateKey(serviceAccountPrivateKey)
.setServiceAccountId(Config.SERVICE_ACCOUNT_ID)
.setServiceAccountUser(Config.SERVICE_ACCOUNT_USER)
.build();
drive = new Drive.Builder(t, jsonFactory, null).setHttpRequestInitializer(gc).setApplicationName(Config.GAE_APPLICATION_NAME).build();

// THIS WORKS
Changes.List request = drive.changes().list();
ChangeList changes = request.execute();

// THIS DOES NOT WORK
Channel channel = new Channel();
channel.setId(UUID.randomUUID().toString());
channel.setType("web_hook");
channel.setAddress(Config.PUSH_NOTIFICATION_ADDRESS);
Channel c = drive.changes().watch(channel).execute();


-------------- REQUEST  --------------
Accept-Encoding: gzip
Authorization: Bearer XXX
User-Agent: XXX Google-HTTP-Java-Client/1.17.0-rc (gzip)
Content-Type: application/json; charset=UTF-8
Content-Length: 118

curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: Bearer XXX' -H 'User-Agent: XXX Google-HTTP-Java-Client/1.17.0-rc (gzip)' -H 'Content-Type: application/json; charset=UTF-8' -d '@-' -- 'https://www.googleapis.com/drive/v2/changes/watch' << $$$
{"address":"XXX","id":"8078114c-fba0-44e7-a34c-cb391ea40061","type":"web_hook"}

-------------- RESPONSE --------------
401 OK
www-authenticate: Bearer realm="https://accounts.google.com/AuthSubRequest", error=invalid_token

-------------- REQUEST  --------------

-------------- RESPONSE --------------
200 OK
{
  "access_token" : XXX,
  "token_type" : "Bearer",
  "expires_in" : 3600
}

-------------- REQUEST  --------------
...

-------------- RESPONSE --------------
401 OK
www-authenticate: Bearer realm="https://accounts.google.com/AuthSubRequest", error=invalid_token
...

...

more similar request-response occurs
...

-------------- RESPONSE --------------
200 OK
content-type: application/json; charset=utf-8
cache-control: no-cache, no-store, max-age=0, must-revalidate
pragma: no-cache
expires: Fri, 01 Jan 1990 00:00:00 GMT
date: Wed, 28 May 2014 20:51:19 GMT
content-disposition: attachment; filename="json.txt"; filename*=UTF-8''json.txt
content-encoding: gzip
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
server: GSE
alternate-protocol: 443:quic
transfer-encoding: chunked

{
  "access_token" : XXX,
  "token_type" : "Bearer",
  "expires_in" : 3600
}

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "push.webhookUrlUnauthorized",
    "message": "Unauthorized WebHook callback channel: XXX"
   }
  ],
  "code": 401,
  "message": "Unauthorized WebHook callback channel: XXX"
 }
}




Dne čtvrtek, 22. května 2014 7:25:01 UTC+2 jeffrey...@myshowing.co napsal(a):

he...@captured.io

unread,
Sep 4, 2014, 1:33:56 PM9/4/14
to google-ca...@googlegroups.com
Did you ever managed to solve this? I'm having the exact same problem

Christian

unread,
Nov 19, 2014, 8:23:56 AM11/19/14
to google-ca...@googlegroups.com
Anyone else has ideas on this problem .... I am having the same problem and cannot register for push notifications.

Markus Welter

unread,
Nov 20, 2014, 1:49:22 PM11/20/14
to google-ca...@googlegroups.com
I also have the same problem. I have one developer account and added a few google accounts where I requested calendar permissions. Everything else works fine, but adding a watch results in the mentioned error message...

Lucia Fedorova

unread,
Nov 24, 2014, 7:33:30 PM11/24/14
to google-ca...@googlegroups.com
Hi all,
please make sure to follow the steps to correctly verify that the domain indeed belongs to you here: https://support.google.com/webmasters/answer/35179
It must be a https endpoint and the same endpoint must also be present in the developer console as per instructions here: https://developers.google.com/google-apps/calendar/v3/push#registering

mizes...@gmail.com

unread,
Mar 9, 2018, 8:56:42 AM3/9/18
to Google Calendar API
Does anyone had able to setup watch or PUSH Notification on Google Drive?

I have followed all the steps and https endpoint, even then having same issue and unable to create watch or push notification

"reason": "push.webhookUrlUnauthorized",
 "message": "Unauthorized WebHook callback channel: https://wewew.xxxx.yyy

 "code": 401,
        "message": "Unauthorized WebHook callback channel: https://wewew.xxxx.yyy"

Malena Mesarina

unread,
Apr 18, 2018, 1:56:50 AM4/18/18
to Google Calendar API
HI I have the same problem , if you found a solution could you please share with me. 
thanks!

-Malena

Artemius Pompilius

unread,
Oct 8, 2018, 10:47:07 AM10/8/18
to Google Calendar API
I confirmed my domain, checked my SSL, but problem hasn't gone.
Finally the solution was use Service Acconut Key in Google Developers Console (not API Key and not OAuth client ID).

среда, 18 апреля 2018 г., 8:56:50 UTC+3 пользователь Malena Mesarina написал:
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages