首页 > 解决方案 > 为什么 Google Drive/Files/List 能从一个共享驱动器中找到文件,而不能从另一个共享驱动器中找到文件?

问题描述

我们正在开发一种工具,它可以下载 Google Drive 中的所有电子表格并将它们发送到 MySQL。这非常适合“我的云端硬盘”。现在我们已经“升级”到 G Suite for Business,并且发现访问共享云端硬盘存在这个问题。

这是使用服务帐户。列出了一个共享驱动器中的文件,但未列出另一个共享驱动器中的文件。corpora如果我们指定和 ,将列出另一个驱动器中的文件driveId

我检查了以下权限:

我正在使用 Google Drives API 列出这样的文件:

$this->googleClient->setScopes(\Google_Service_Drive::DRIVE_METADATA_READONLY);
$googleService = new \Google_Service_Drive($this->googleClient);
$this->throttleIfNecessary();

// Collect file list
$optParams = [
    //'corpora'=> 'domain',
    'orderBy' => 'modifiedTime',
    'pageSize' => $count, // Google default is 100, maximum is 1000
    'q' => "mimeType = 'application/vnd.google-apps.spreadsheet' and modifiedTime >= '$modifiedTime'",
    #'fields' => 'nextPageToken, files(id,modifiedTime)',
    'fields' => 'files(id,modifiedTime)',
    'supportsAllDrives' => 'true',
    'includeItemsFromAllDrives' => 'true',
    'includeTeamDriveItems' => 'true',
    'supportsTeamDrives' => 'true',
    //'corpora' => 'drive',
    //'driveId' => 'oesntuheunt' // PMT Owners Shared Drive
];
print_r($optParams);
// https://developers.google.com/drive/api/v3/reference/files/list
$results = $googleService->files->listFiles($optParams);
print_r($results);

我将如何更新它,以便服务帐户可以访问所有共享驱动器中的所有文件?`

标签: google-apigoogle-drive-apigoogle-apis-explorer

解决方案


推荐阅读