Google Drive Push Notifications 在一小时后停止工作

Google Drive Push Notifications stops working in a hour

我通过推送通知订阅文件通知API:

https://developers.google.com/drive/api/v3/push

订阅后我会立即尝试编辑文件 - 将发送通知。

但是,我尝试在 1 小时后编辑文件 - 但不会发送通知。

为什么会这样?这与用户访问令牌的过期时间有关吗? (访问令牌只能存在一小时)

official documentation 声明如下:

Note: For the Drive API, the maximum expiration time is 86400 seconds (1 day) after the current time for File resources and 604800 seconds (1 week) for Changes. If you don’t set the expiration property in your request, the expiration time defaults to 3600 seconds after the current time.

这意味着您在发送手表请求时没有设置过期时间,因此您需要每小时刷新一次手表。为避免每小时刷新一次,请在您的监视请求中包含一个到期时间,然后根据 instructions here.

刷新它