Search code examples
push-notificationgoogle-drive-api

Set Google Drive Push Notification to Never Expire


I have read the Google Drive API for Push Notifications, and it appears that there is a way to set a channel to never expire, yet there is no documentation I can find on how to do so. I have tried setting the ttl parameter to 0 and null, and both times the API returns with an expiration time of 3600 seconds from the time of the call (default). See this excerpt for where the document alludes to being able to set a channel to never expire:

Renewing notification channels

A notification channel can have an expiration time, with a value determined either by your request or by any Drive API internal limits or defaults (the more restrictive value is used). The channel's expiration time, if it has one, is included in the information returned by the watch method. In addition, the expiration time is included in every notification message your application receives for this channel in the X-Goog-Channel-Expiration HTTP header.

Currently there is no automatic way to renew a notification channel. When a channel is close to its expiration, you must create a new one by calling the watch method. As always, you must use a unique value for the id property of the new channel. Note that there is likely to be an "overlap" period of time when the two notification channels for the same resource are active.

The documents also say that there is a 1 day maximum expiration time for files and 1 week for changes channels, but this would be if an expiration is actually defined, no? If there is a way to set no expiration, AKA infinite channel duration, then these shouldn't apply.

Anyone who knows how to set this to never expire (Or if in this case there is no way to) please let me know!


Solution

  • There is no way to set it to forever due to security concerns, that's upper limit is one day.