Implement shared drive support

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. The complexity of your implementation depends on the functionality of your app. To begin, you need to include the supportsAllDrives=true query parameter in your requests when your app performs these operations:

  • files.get
  • files.list
  • files.insert
  • files.update
  • files.patch
  • files.copy
  • files.trash
  • files.untrash
  • files.delete
  • files.touch
  • children.insert
  • parents.insert
  • changes.list
  • changes.getStartPageToken
  • changes.get
  • permissions.list
  • permissions.get
  • permissions.insert
  • permissions.update
  • permissions.patch
  • permissions.delete

The supportsAllDrives=true parameter informs Google Drive that your application is designed to handle files on shared drives.

Applications that read or modify permissions, track changes, or need to search across multiple corpora require additional shared drive functionality. The remainder of this document highlights additional changes required to perform these tasks.

Search for content on a shared drive

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]((/drive/api/v2/search-files).

The files.list method contains the following shared drive-specific fields and query modes:

  • driveId — ID of shared drive to search.
  • includeItemsFromAllDrives — Whether shared drive items should be included in results. If not present or set to false, then shared drive items are not returned.

  • corpora — Bodies of items (files/documents) to which the query applies. Supported bodies are default, domain, drive, and allDrives. Prefer default or drive to allDrives for efficiency.

  • supportsAllDrives — Whether the requesting application supports both My Drives and shared drives. If false, then shared drive items are not included in the response.

The following query modes are specific to shared drives:

includeItemsFromAllDrives corpora Query Description
true default Queries files that the user has accessed, including both shared drive and My Drive files.
true drive Queries all items in the specified shared drive. driveId must be specified in the request.
true allDrives Queries files that the user has accessed and all shared drives in which they are a member. Note that the response may include incompleteSearch : true, indicating that some corpora were not searched for this request.
true domain Queries files that are shared to the domain, including both shared drive and My Drive files.

Track changes on a shared drive

The changes.get and changes.list methods have several parameters specific to shared drives:
  • driveId — The shared drive from which changes are returned. If specified, the change IDs refer to changes within the shared drive, not changes to the files shown to the user. To refer to a specific shared drive change, both the shared drive ID and change ID must be used as an identifier.
  • supportsAllDrives — Whether the requesting application supports shared drives. If false, then shared drive items, including both shared drives and files within a shared drive, are not returned.
  • includeItemsFromAllDrives — Whether shared drive files or changes should be included in the list of changes.

The following query modes are specific to shared drives:

includeItemsFromAllDrives driveId Query Description
true No Changes are reflective of changes to files inside or outside of shared drives that the user has accessed, as well as changes to shared drives in which the user is a member.
true Yes Changes are reflective of changes to the particular shared drive that was specified and items inside that shared drive.

For additional details about change log behavior, refer to Change Logs.

Enable shared drive support in the Drive UI

To access shared drive content using the Drive UI, ensure you have checked the "Shared drives support" in the Google API Console. For further information, refer to Configure a Drive UI integration.

Using the file picker with shared drives

The file picker supports selecting items in shared drives. For details around enabling shared drives support and adding shared drives view in the file picker, refer to Picker API.

Next steps

Continue to Manage shared drives for help on creating shared drives and managing shared drive permissions.