公共共享文件夹中的Google驱动器列表文件

问题描述 投票:0回答:1

我有一个经过身份验证的Google客户端,我想列出其他人的公用文件夹中的文件(我认为共享的文件夹与否是不相关的,因为它是公用的)]

这是我在NodeJS中的代码

  const drive      = google.drive({ version: 'v3', auth });
  let fconf        = {};
  fconf.maxResults = 10;
  fconf.orderBy    = "createdTime"; 
  fconf.driveId    = "xyz-badfd134343example";
  fconf.includeItemsFromAllDrives = true;
  fconf.q          = "application/vnd.google-apps.spreadsheet";
  fconf.supportsTeamDrives = true; 
  fconf.corpa              = "drive";
  fconf.supportsAllDrives  = true;

  drive.files.list(fconf, function(e,d)
  {
    console.log("e,d",e,d);
  });
 }

注意:文档中没有'folderId'选项:https://developers.google.com/drive/api/v3/reference/files/list-仅是driveId选项

尽管我将corpa设置为“驱动器”和驱动器ID,但出现以下错误

{ Error: The driveId parameter must be specified if and only if corpora is set to drive.
    at Gaxios.<anonymous> (/home/ubuntu/c/node_modules/gaxios/build/src/gaxios.js:73:27)
    at Generator.next (<anonymous>)
    at fulfilled (/home/ubuntu/c/node_modules/gaxios/build/src/gaxios.js:16:58)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  response: 
   { config: 
      { url: 'https://www.googleapis.com/drive/v3/files?driveId=examplexyz&includeItemsFromAllDrives=true&corpa=drive&supportsAllDrives=true',
        method: 'GET',
        paramsSerializer: [Function],
        headers: [Object],
        params: [Object],
        validateStatus: [Function],
        responseType: 'json' },
     data: { error: [Object] },
     headers: 
      { 'alt-svc': 'quic=":443"; ma=2592000; v="46,43",h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000',
        'cache-control': 'private, max-age=0',
        connection: 'close',
        'content-encoding': 'gzip',
        'content-type': 'application/json; charset=UTF-8',
        date: 'Thu, 24 Oct 2019 00:38:10 GMT',
        expires: 'Thu, 24 Oct 2019 00:38:10 GMT',
        server: 'GSE',
        'transfer-encoding': 'chunked',
        vary: 'Origin, X-Origin',
        'x-content-type-options': 'nosniff',
        'x-frame-options': 'SAMEORIGIN',
        'x-xss-protection': '1; mode=block' },
     status: 403,
     statusText: 'Forbidden' },
  config: 
   { url: 'https://www.googleapis.com/drive/v3/files?driveId=examplexyz&includeItemsFromAllDrives=true&corpa=drive&supportsAllDrives=true',
     method: 'GET',
     paramsSerializer: [Function],
     headers: 
      { 'Accept-Encoding': 'gzip',
        'User-Agent': 'google-api-nodejs-client/0.7.2 (gzip)',
        Authorization: 'Bearer something',
        Accept: 'application/json' },
     params: 
      { driveId: 'examplexyz',
        includeItemsFromAllDrives: true,
        corpa: 'drive',
        supportsAllDrives: true },
     validateStatus: [Function],
     responseType: 'json' },
  code: 403,
  errors: 
   [ { domain: 'global',
       reason: 'teamDriveIdRequiresTeamDriveCorpora',
       message: 'The driveId parameter must be specified if and only if corpora is set to drive.' } ] } undefined
close the queue { success: true }
node.js google-drive-api
1个回答
0
投票
    您想从公共共享文件夹中检索文件列表。
    • 您只想检索电子表格文件。
© www.soinside.com 2019 - 2024. All rights reserved.