"Required parameter: pageToken" 尝试注册 Google Drive webhook 时出错

"Required parameter: pageToken" error when attempting to register Google Drive webhooks

按照指南 here,我正在尝试设置 Google 驱动器 "push notifications"(webhooks)以便我可以监视所有文件更改。我需要向 https://www.googleapis.com/drive/v3/changes/watch 发送一个 one-off POST 请求到最初 "register" webhook。但是我似乎无法成功地做到这一点;使用 curl 我收到 400 Bad Request 回复。

这是我通过 curl 发出的 HTTP 请求:

curl 'https://www.googleapis.com/drive/v3/changes/watch' \
-X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer access_token' \
--data-binary '{"id": "webhook", "type": "web_hook", "address": "https://example.com/webhooks", "token": "example"}' \
-vvvv

回复:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "Required parameter: pageToken",
    "locationType": "parameter",
    "location": "pageToken"
   }
  ],
  "code": 400,
  "message": "Required parameter: pageToken"
 }
}

什么是 pageToken 我从哪里得到它?另外,我如何将它包含在请求中(例如作为 header)?指南中没有提到它。

直接来自文档

Changes: watch Subscribes to changes for a user.
Required query parameters
pageToken string

The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.

如果这是第一个请求,那么您将需要使用 getStartPageToken 方法获取第一个令牌,然后页面令牌将成为响应的一部分。