I am using Google Calendar Push Notifications. All is working well and I register my channel with no issue. Changes to the calendar result in a notification as expected.>
I too have been plagued by this apparent bug in the Calendar API. After two days of testing I have uncovered the following:
This bug only seems to manifest when you watch() a calendar using a Service Account (which is always the case for Google Apps Marketplace apps). I only tested watching a secondary calendar, so I can't confirm if the problem exists when watching a primary calendar.
When you include "params": { "ttl" : 172800 } you will get a channel back with an expiration header set for 2 days from now. However, notifications will STOP being sent after 1 hour, indicating the channel is dropped, and that Google Calendar is not correctly respecting the expiration.
If you include "params": { "ttl" : 172800 } and watch() a calendar with a normal access token from a regular oAuth2 flow then the channel is created with the specified expiration AND notifications are sent as expected up until the expiration. This is true whether you are watching a Gmail account's calendar OR a Google App account's calendar - as long as you use regular OAuth2 and NOT a Service Account.
I tried using the undocumented
-
body = { "expiration" : MILLISECONDS_SINCE_EPOCH, ....}.
instead of
body = { "params": { "ttl" : 172800 }, ....}.
This is what the Google API Python Client Library uses and it had no effect. Channels were created with the correct expiration, but expired after an hour when using a Service Account.
This is a particularly bad bug because it appears a channel is created correctly, but it expires early and you have no way of verifying what channels are active for a particular resource.
The only workaround I've figured out so far is to renew every channel after an hour. This is NOT a long-term solution. I will be using over 300,000 API calls per day just to keep channels active, which is a huge chunk of my quota. If things were working correctly I would only need to renew channels at most once a week, not 24 times a day.