Notice: important security update for Drive document URLs and resource keys. For more information, refer to Access link-shared files using resource keys

Access link-shared files using resource keys

A file that is shared with the link can only be discovered by users that can access the file as a result of a type=user or type=group permission. Requests from users that only have access to these link-shared files via a type=domain or type=anyone permission, may require a resource key.

This resource key requirement only applies to a subset of old files.

For more information about permissions, see Share files, folders and drives.

Read the resource key from the file

The Drive API returns a file's resource key on the read-only resourceKey field of the File resource.

If the file is a shortcut, the resource key for the target of the shortcut is returned on the read-only shortcutDetails.targetResourceKey field.

Set the resource key on the request

Resource keys for any files referenced by requests to the Drive API are set on the X-Goog-Drive-Resource-Keys HTTP header.

Syntax

A pair of file ID and resource key are set on the header using a forward slash (/) separator. The header is built by combining all these file ID and resource key pairs using comma (,) separators.

For example, consider a request to move file fileId1 from folder fileId2 to folder fileId3. Let's assume the resource keys for these three files are resourceKey1, resourceKey2, and resourceKey3, respectively. The header built from these values using forward slash and comma separators is:

X-Goog-Drive-Resource-Keys: fileId1/resourceKey1,fileId2/resourceKey2,fileId3/resourceKey3