Google drive api 驱动器列表文件没有';当“字段”存在时,不能进行下一个GetToken
运行此列表文件时,没有Google drive api 驱动器列表文件没有';当“字段”存在时,不能进行下一个GetToken,google-drive-api,Google Drive Api,运行此列表文件时,没有nextPageToken,只有文件[] curl \ 'https://www.googleapis.com/drive/v3/files?fields=files(id%2C%20name)&key=[YOUR_API_KEY]' \ --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \ --header 'Accept: application/json' \ --compressed
nextPageToken
,只有文件[]
curl \
'https://www.googleapis.com/drive/v3/files?fields=files(id%2C%20name)&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
结果:
{
"files": [
{
"id": "1",
"name": "1"
},
...
{
"id": "2",
"name": "2"
}
]
}
{
"kind": "drive#fileList",
"nextPageToken": "~!!~AI9FV7TN...",
"incompleteSearch": false,
"files": [
{
"kind": "drive#file",
"id": "1",
"name": "1",
"mimeType": "application/vnd.google-apps.spreadsheet"
},
...
将字段
参数留空,将返回nextPageToken
curl \
'https://www.googleapis.com/drive/v3/files?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
{
"nextPageToken": "###",
"files": [
{"id": "###", "name": "###"},
{"id": "###", "name": "###"},
,
,
,
]
}
结果:
{
"files": [
{
"id": "1",
"name": "1"
},
...
{
"id": "2",
"name": "2"
}
]
}
{
"kind": "drive#fileList",
"nextPageToken": "~!!~AI9FV7TN...",
"incompleteSearch": false,
"files": [
{
"kind": "drive#file",
"id": "1",
"name": "1",
"mimeType": "application/vnd.google-apps.spreadsheet"
},
...
这是一个bug还是有办法获取nextpGetOken
并限制返回的字段?for字段
意味着它应该工作:
注意:驱动器API支持数据分页的查询参数(maxResults和nextPageToken)。对于支持这些参数的API,请使用这些参数将每个查询的结果减少到可管理的大小。否则,可能无法实现部分响应可能带来的性能增益
当“文件:列表”方法使用fields=files(id,name)
时,返回文件id和文件名。在这种情况下,字段的值是files.id
和files.name
<代码>下一个GetOken不包括在字段中。这样,就不会返回页面令牌。如果未使用字段
,则下一个getoken、未完成搜索、种类、文件(id、名称、种类、mimeType)的字段
似乎是默认值。所以我认为这不是一个bug,它可能是当前的规范
因此,当您使用https://www.googleapis.com/drive/v3/files?fields=files(id%2C%20name)
,请在字段中包含nextPageToken
,如下所示
修改的curl命令:
- 在这种情况下,
字段
是下一个getoken,文件(id,name)
结果:
当运行上述curl命令时,将返回以下结果
curl \
'https://www.googleapis.com/drive/v3/files?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
{
"nextPageToken": "###",
"files": [
{"id": "###", "name": "###"},
{"id": "###", "name": "###"},
,
,
,
]
}
参考:
这很有效。我专注于文件()
,并尝试将nextPageToken
放在那里,但这是错误的级别。我向文档页面提交了一个建议,以展示可能的混合级别。@Jim感谢您的回复。我很高兴你的问题解决了。