Serhii
Serhii

Reputation: 7543

Google Calendar V3 API Push notification via java client

I need subscribe for Google Calendar API v3 Push Notifications. I have checked documentation - it provides useful API details. I have checked java client library. It contains useful classes...

Trying:

com.google.api.services.calendar.Calendar calendar = initObject();
...
calendar.calendarList().get("[email protected]").execute();

As result I have CalendarListEntry map with my calendar info. Trying use same calendarClient object:

calendar.calendarList().watch(channel).execute();

in result:

17:46:26,540 ERROR # c.n.c.c.g.GoogleCalendarClient.watchCalendarList com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized

It seems I have an authorization issue. I think I should not have one because of I can try one more time same client object and it returns correct result. Also I have considered case to use optional token field - no changes.

If someone needs my channel object: 17:58:38,022 INFO # {"address":"https://myPersonalVerifiedByGoogleAddr/google/calendars/","id":"4ac3e9e3-8428-405e-a8ed-6cf0e4fa25ff","payload":false,"type":"web_hook"}

address - my inet address verified by google
id - generated
payload - false (because of no content in my request)
type - web_hook (following google doc)

I have no ideas how to fix unauthorized in watch request, because of client is authorized (I would not be able to load calendar info).

Upvotes: 0

Views: 775

Answers (1)

Mr.Rebot
Mr.Rebot

Reputation: 6791

You may want to try testing it by sending http request to validate if it is just an OAuth token issue. Next is to validate if you have done all the required steps to make a watch request. This would narrow down the possible reasons you encounter the issue.

Also check that in the docs it stated that "the Google Calendar API will be able to send notifications to this HTTPS address only if there is a valid SSL certificate installed on your web server."

Upvotes: 1

Related Questions