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感谢您的回复。我很高兴你的问题解决了。