admin管理员组

文章数量:1391975

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.

本文标签: