I\'m trying to watch for changes in Google Drive, and getting 401 Exception. Searching here, i found that people have detailed messages, why they are not unauthorized though
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:
Register the domain of your receiving URL. ...
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.
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.