最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Google Drive API Webhooks - single change in a shared drive causes notifications on all other drive webhooks - Stack Overflow

programmeradmin1浏览0评论

Currently running into an issue where when I apply a change to a shared drive, rather than just the shared drive's watch channel getting notified, all 4 channels get notified. Causing 4 webhooks to send on a single change from 1 drive. I've tried doing different combinations of settings restrictToMyDrive, supportsAllDrives, includeItemsFromAllDrives but they don't seem to work. Is it possible to get notified for a change in a shared drive specifically from it's corresponding channel?

Using the /drive/v3/changes/watch endpoint, I created a webhook on every drive returned from the /drive/v3/drives endpoint. For each drive I generated a startPageToken from the /drive/v3/changes/startPageToken endpoint:

{
  "driveId": [drive_id],
  "supportsAllDrives": "true"
}

and created a watch channel using the POST /drive/v3/changes/watch endpoint with a request body of:

{
  "driveId": [drive_id],
  "pageToken": [page_token from startPageToken response],
  "includeRemoved": "true"
  "restrictToMyDrive": "true"
}

For example, I have 3 shared drives, so I've set 3 watch channels at this point.

At the end of the loop I created another watch channel for the account (to catch all changes as an extra layer of security) to the POST /drive/v3/changes/watch endpoint with a request body of:

{
  "pageToken": [page_token],
  "includeRemoved": "true",
  "restrictToMyDrive": "false",
  "supportsAllDrives": "true",
  "includeCorpusRemovals": "true",
  "includeItemsFromAllDrives": "true"
}

So in total I have 4 watch channels now.

For a single change in a shared drive, all 4 channels get notified of a change and send 4 webhooks for a single change.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论