Google日历推送通知:未经授权的webhook通话

时间:2017-03-01 13:46:20

标签: node.js google-api webhooks google-calendar-api

目前,我们正在开发一款处理谷歌日历的iPhone应用程序。需要将日历事件同步到服务器端。一切正常。

但是对于推送通知,我们正在关注this process

每当我们发布请求时:     https://www.googleapis.com/calendar/v3/calendars/email@gmail.com/events/watch

带参数

"id":Unique string ( channel id) ,  
"type": "web_hook",
"address": "https://abc-api.herokuapp.com/user/notifications"

在标题中,我们正在发送

Authorization : **Bearer 'Access_token'** 

和内容类型:json

我们已在google api控制台中添加域作为授权域

Access_token是用户的帐户访问令牌。

我们正在接受"未经授权的webhook通话"错误。

    {
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "push.webhookUrlUnauthorized",
        "message": "Unauthorized WebHook callback channel: https://abc-api.herokuapp.com/user/notifications"
      }
    ],
    "code": 401,
    "message": "Unauthorized WebHook callback channel: https://abc-api.herokuapp.com/user/notifications"
  }
}

此处有谁可以帮助我们解决问题?

2 个答案:

答案 0 :(得分:2)

You might want to check this post, providing solution like verifying if your domain have a valid (not self-signed) SSL license. Also in google-api-php-client GitHub, instead of setting https://example.com/google/push (resulted in Unauthorized WebHook callback channel) or https://www.example.com/google/push (allowed me to successfully open channel, and object has been returned, however webhook has not been fired) as address they tried https://www.example.com/google/push/index.php and worked.

答案 1 :(得分:0)

一个潜在的问题是,如果您正在使用Google的“试用”部分进行测试。它没有说明,但这个特殊要求在那里不起作用。

否则,您在地址中提供的域名需要执行一些操作。首先,您需要确保谷歌开发者控制台中的verified用于您正在使用api的应用程序。此外,您需要add the website property to your search console(即使它只是一个api)并验证所有权。

此外,一旦您通过未经授权的地址问题,您将收到另一个错误,要求提供resourceId。