drive.changes().watch returns GoogleJsonResponseException: 401 Unauthorized without any message

落爺英雄遲暮 提交于 2019-12-01 10:52:38

After spending few hours and reading more carefully the documentation, I've finally found the problem.

As written in Push Notification doc (https://developers.google.com/drive/v3/web/push):

To use push notifications, you need to do three things:

  1. Register the domain of your receiving URL. ...

  2. Set up your receiving URL, or "Webhook" callback receiver.

    This is an HTTPS server that handles the API notification messages that are triggered when a resource changes.

  3. Set up a notification channel for each resource endpoint you want to watch.

    A channel specifies routing information for notification messages. As part of the channel setup, you identify the specific URL where you want to receive notifications. Whenever a channel's resource changes, the Drive API sends a notification message as a POST request to that URL.

Which means you should have a domain and you should confirm it at google, before you can use watch API.

P.S. i still think that response GoogleJsonResponseException: 401 Unauthorized is ridiculous in this case, but hope it will help other who face the same issue.

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