<p>通过向列表方法添加一些参数,我可以列出共享驱动器文件,而无需模拟用户,如<a href="https://developers.google.com/drive/api/v3/enable-shareddrives" rel="nofollow noreferrer">google documentation</a>所述:</p>
<blockquote>
<h2>Implement shared drive support</h2>
<p>Shared drives follow different organization, sharing, and ownership models from My Drive. If your app is going to create and manage files on shared drives, you must implement shared drive support in your app. To begin, you need to include the <strong>supportsAllDrives=true</strong> query parameter in your requests when your app performs these operations:</p>
<p>files.get, files.list, files.create, files.update, files.copy, files.delete, changes.list, changes.getStartPageToken, permissions.list, permissions.get, permissions.create, permissions.update, permissions.delete</p>
</blockquote>
<blockquote>
<h2>Search for content on a shared drive</h2>
<p>Use the files.list method to search for shared drives. This section covers shared drive-specific fields in the files.list method. To search for shared drive, refer to Search for files and folders.</p>
<p>The files.list method contains the following shared drive-specific fields and query modes:</p>
<p><strong>driveId</strong> — ID of shared drive to search.</p>
<p><strong>includeItemsFromAllDrives</strong> — Whether shared drive items should be included in results. If not present or set to false, then shared drive items are not returned.</p>
<p><strong>corpora</strong> — Bodies of items (files/documents) to which the query applies. Supported bodies are user, domain, drive, and allDrives. Prefer user or drive to allDrives for efficiency.</p>
<p><strong>supportsAllDrives</strong> — Whether the requesting application supports both My Drives and shared drives. If false, then shared drive items are not included in the response.</p>
</blockquote>
<p><strong>示例</strong></p>
<pre><code>service.files().list(includeItemsFromAllDrives=True, supportsAllDrives=True, pageSize=10, fields="nextPageToken, files(id, name,modifiedTime)").execute()
</code></pre>
<p>请记住,文件夹或文件需要与服务帐户共享</p>