Access shared drivesSource:
A shared drive supports files owned by an organization rather than an individual user. Shared drives follow different sharing and ownership models from a specific user's "My Drive". Shared drives are the successors to the earlier concept of Team Drives.
How to capture a shared drive or files/folders that live on a shared drive for downstream use:
dribblewith metadata on shared drives themselves. You will need this in order to use a shared drive in certain file operations. For example, you can specify a shared drive as the parent folder via the
pathargument for upload, move, copy, etc. In that context, the id of a shared drive functions like the id of its top-level or root folder.
dribblewith metadata on files, including folders. Both can be directed to search for files on shared drives using the optional arguments
Regard the functions mentioned above as the official "port of
entry" for working with shared drives. Use these functions to capture your
target(s) in a
dribble to pass along to other googledrive functions.
The flexibility to refer to files by name or path does not apply as broadly
to shared drives. While it's always a good idea to get things into a
dribble early, for shared drives it's often required.
To search one specific shared drive, pass its name, marked id, or
shared_drive somewhere in the call, like so:
drive_find(..., shared_drive = "i_am_a_shared_drive_name") drive_find(..., shared_drive = as_id("i_am_a_shared_drive_id")) drive_find(..., shared_drive = i_am_a_shared_drive_dribble)
The value provided to
shared_drive is pre-processed with
To search other collections, pass the
corpus parameter somewhere in the
call, like so:
drive_find(..., corpus = "user") drive_find(..., corpus = "allDrives") drive_find(..., corpus = "domain")
Possible values of
corpus and what they mean:
"user": Queries files that the user has accessed, including both shared drive and My Drive files.
"drive": Queries all items in the shared drive specified via
shared_drive. googledrive automatically fills this in whenever
"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 (currently, googledrive does not surface this). Prefer
"domain": Queries files that are shared to the domain, including both shared drive and My Drive files.
Here is some of the best official Google reading about shared drives:
Team Drives is being renamed to shared drives from Google Workspace blog
Upcoming changes to the Google Drive API and Google Picker API from the Google Cloud blog
Get started with shared drives:
https://support.google.com/a/users/answer/9310351from Google Workspace Learning Center
Best practices for shared drives:
https://support.google.com/a/users/answer/9310156from Google Workspace Learning Center
googledrive implements shared drive support as outlined here:
Users shouldn't need to know any of this, but here are details for the curious. The extra information needed to search shared drives consists of the following query parameters:
corpora: Where to search? Formed from googledrive's
driveId: The id of a specific shared drive. Only allowed -- and also absolutely required -- when
corpora = "drive". When user specifies a
shared_drive, googledrive sends its id and also infers that
corporashould be set to
includeItemsFromAllDrives: Do you want to see shared drive items? Obviously, this should be
TRUEand googledrive sends this whenever shared drive parameters are detected.
supportsAllDrives: Does the sending application (googledrive, in this case) know about shared drive? Obviously, this should be
TRUEand googledrive sends it for all applicable endpoints, all the time.