unable to receive push notification for Google calender

夙愿已清 提交于 2020-01-16 04:54:06

问题


I am trying to watch events resource based on given example using API explorer and Chrome Advanced Rest Client. https://developers.google.com/google-apps/calendar/v3/push#watch_request_examples

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",
 "address": "https://www.example.com/WebHook/Index",
 "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 have already got ssl certificate which is mandatory to receive push notifications

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

  • Posted same question on google group of calender api, but no response yet. https://groups.google.com/forum/#!topic/google-calendar-api/ZHKwm2xWuNE

can anybody guide, whats wrong with request ?


回答1:


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




回答2:


Your auth token may be incorrect. Please make sure you are using correct auth token for the calendar you are trying to set watch for




回答3:


The one step I was missing to get this working was to actually enable the Calendar API in the console. The 401 push.webhookUrlUnauthorized error is really not helpful here.




回答4:


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 :)



来源:https://stackoverflow.com/questions/19463049/unable-to-receive-push-notification-for-google-calender

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!