Google Drive API V3-推送通知 [英] Google Drive API V3 - Push Notifications
问题描述
自昨天早上以来,我一直在坚持使用Google云端硬盘API请求.
Since Yesterday morning I'm stuck with a google drive API request.
如此处所述: https://developers.google.com/drive/api /v3/push
我正尝试订阅发送此请求的通知:
I'm trying to subscribe to notifications sending this request :
网址: https://www.googleapis.com/drive/v3/changes /watch
Header :
Content-type: application/json
Authorization: Bearer my_auth_token
{
"id":"An ID generated",
"type":"web_hook",
"address":"my callback address",
}
响应是带有此正文的代码400:
The response is a code 400 with this body :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: pageToken",
"locationType": "parameter",
"location": "pageToken"
}
],
"code": 400,
"message": "Required parameter: pageToken"
}
}
此订阅请求并非必需此参数,而是此请求(相同的URL.): https://developers.google.com/drive/api/v3/reference/changes/watch
This parameter isn't required according for this subscription request but for this one (same url..) : https://developers.google.com/drive/api/v3/reference/changes/watch
我丢失/误解了什么吗?文档是否存在问题?
Am I missing / misunderstanding something or is there a problem with the documentation ?
谢谢
推荐答案
pageToken
参数是用于在下一页继续上一个列表请求的令牌.如我们所见,
The pageToken
parameter is 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, as we see here.
因此,您应该将pageToken
作为参数传递给URL:
Therefore, you should pass the pageToken
as a parameter to your URL:
网址:https://www.googleapis.com/drive/v3/changes/watch?pageToken=[YOUR_PAGE_TOKEN_NUMBER_HERE]
例如:https://www.googleapis.com/drive/v3/changes/watch?pageToken=101
使用GET https://www.googleapis.com/drive/v3/changes/startPageToken
获取列出的起始pageToken并观察将来的更改可能会很有趣.请参见此处
It might be interesting to use GET https://www.googleapis.com/drive/v3/changes/startPageToken
to gets the starting pageToken for listing and watch future changes. See here
这篇关于Google Drive API V3-推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!