共有ドライブ API と My Drive API の違い
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
共有ドライブは、マイドライブとは異なる組織、共有、所有権のモデルに従います。そのため、共有ドライブのコンテンツに対しては、マイドライブの一部の操作が許可されていません。
このガイドでは、files
リソースと changes
リソースにおける共有ドライブ固有の API の違いについて説明します。
ファイル リソース
files
リソースの次のフィールドは、共有ドライブ内のファイルに対してのみ入力されます。
hasAugmentedPermissions
: このファイルでファイル アクセス権が直接付与されているユーザーがいるかどうか。
capabilities/canAddFolderFromAnotherDrive
: 現在のユーザーが別のドライブ(別の共有ドライブまたはマイドライブ)のフォルダをこのフォルダに追加できるかどうか。
capabilities/canDeleteChildren
: 現在のユーザーがこのフォルダの子を削除できるかどうか。
capabilities/canMoveChildrenOutOfDrive
: 現在のユーザーがこのフォルダの子を共有ドライブ外に移動できるかどうか。
capabilities/canMoveChildrenWithinDrive
: 現在のユーザーがこのフォルダの子を共有ドライブ内で移動できるかどうか。
capabilities/canMoveItemWithinDrive
: 現在のユーザーがこの共有ドライブ アイテムを共有ドライブ内で移動できるかどうか。
capabilities/canReadDrive
: 現在のユーザーが、このファイルが属する共有ドライブへの読み取りアクセス権を持っているかどうか。
capabilities/canTrashChildren
: 現在のユーザーがこのフォルダの子を削除できるかどうか。
driveId
: ファイルが保存されている共有ドライブの ID。
trashingUser
: ファイルが明示的にゴミ箱に移動された場合、そのファイルをゴミ箱に移動したユーザー。
trashedTime
: アイテムがゴミ箱に移動された時刻。古い Drive API v2 を使用している場合、このフィールドは trashedDate
と呼ばれます。
共有ドライブ内のファイルについては、次のフィールドは入力されません。
permissions
: 共有ドライブのアクセス制御リスト(ACL)のサイズが大きくなる可能性があるため、権限はファイルの一部として返されません。permissions.list
メソッド(ページネーションをサポート)を使用して、共有ドライブ内のファイルまたは共有ドライブ フォルダの権限を一覧表示します。
owners
、ownerNames
、ownedByMe
: 共有ドライブ内のファイルは、個々のユーザーではなく共有ドライブが所有します。
folderColorRgb
: フォルダに個別に色を付けることはできません。
shared
: 共有ドライブ内のすべてのアイテムが共有されます。
writersCanShare
: 共有ドライブでロールごとに共有を制限することはできません。
次のフィールドは、ユーザーがアイテムに対するファイル アクセス権限を付与されている場合にのみ設定されます。
sharedWithMeDate
sharingUser
次のフィールドは、共有ドライブで使用する際に特別な考慮事項が必要です。
parents.isRoot
: このフィールドはマイドライブのルートフォルダでのみ true になり、共有ドライブの最上位フォルダでは false になります。
parents
: リクエストしているユーザーが共有ドライブのメンバーではなく、保護者にアクセスできない場合、保護者は保護者リストに表示されません。また、最上位のフォルダを除き、ファイルが共有ドライブ内にある場合、parents リストには 1 つのアイテムのみが含まれている必要があります。
capabilities/canRemoveChildren
: capabilities/canDeleteChildren
または capabilities/canTrashChildren
を使用します。
リソースを変更
共有ドライブの changes
リソースで、次の新しいフィールドを使用できます。
changeType
: 変更タイプ。有効な値は file
と drive
です。
driveId
: この変更に関連付けられている共有ドライブの ID。
drive
: 更新された共有ドライブの状態。changeType
が drive
で、ユーザーが共有ドライブのメンバーである場合に表示されます。
共有ドライブとコンテンツを同期したり、アクティビティを追跡したりする必要があるアプリケーションでは、追加の変更が必要になる場合があります。詳しくは、ユーザーと共有ドライブの変更履歴を追跡するをご覧ください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[],[],null,["# Shared drive versus My Drive API differences\n\nShared drives follow different organization, sharing, and ownership models from\na My Drive. As such, some My Drive operations\naren't permitted for content in a shared drive.\n\nThis guide outlines shared drive-specific API differences in the `files` and\n`changes` resources.\n\nFile resource\n-------------\n\nThe following fields in the [`files`](/workspace/drive/api/reference/rest/v3/files) resource are\nonly populated for files located within a shared drive:\n\n- `hasAugmentedPermissions`: Whether any users are granted file access directly on this file.\n- `capabilities/canAddFolderFromAnotherDrive`: Whether the current user can add a folder from another drive (a different shared drive or My Drive) to this folder.\n- `capabilities/canDeleteChildren`: Whether the current user can delete children of this folder.\n- `capabilities/canMoveChildrenOutOfDrive`: Whether the current user can move children of this folder outside of the shared drive.\n- `capabilities/canMoveChildrenWithinDrive`: Whether the current user can move children of this folder within the shared drive.\n- `capabilities/canMoveItemWithinDrive`: Whether the current user can move this shared drive item within the shared drive.\n- `capabilities/canReadDrive`: Whether the current user has read access to the shared drive to which this file belongs.\n- `capabilities/canTrashChildren`: Whether the current user can trash children of this folder.\n- `driveId`: The ID of the shared drive where the file is located.\n- `trashingUser`: If the file has been explicitly trashed, the user who trashed it.\n- `trashedTime`: The time that the item was trashed. If you're using the older Drive API v2, this field is called `trashedDate`.\n\nThe following fields aren't populated for files located within a shared drive:\n\n- `permissions`: Due to the potential size of shared drive access control lists (ACLs), permissions aren't returned as part of files. Use the `permissions.list` method, which supports pagination, to list permissions for a file within a shared drive or the shared drive folder.\n- `owners`, `ownerNames`, `ownedByMe`: Files within a shared drive are owned by the shared drive, not individual users.\n- `folderColorRgb`: Folders cannot be colored individually.\n- `shared`: All items in a shared drive are shared.\n- `writersCanShare`: It's not possible to restrict sharing by role in shared drives.\n\nThe following fields are only set when the user has been granted file access\npermissions on an item:\n\n- `sharedWithMeDate`\n- `sharingUser`\n\nThe following fields require special consideration when you use them with shared\ndrives:\n\n- `parents.isRoot`: This field is only true for the My Drive root folder; it's false for the shared drive top-level folder.\n- `parents`: A parent doesn't appear in the parents list if the requesting\n user isn't a member of the shared drive and doesn't have access to the\n parent. In addition, with the exception of the top level folder, the parents\n list must contain exactly one item if the file is located within a shared\n drive.\n\n | **Note:** If you're using the older Drive API v2:\n | - `shareable`: Deprecated. Use `capabilities/canShare`.\n | - `editable`: Deprecated. Use `capabilities/canEdit`.\n | - `copyable`: Deprecated. Use `capabilities/canCopy`.\n | - `canComment`: Deprecated. Use `capabilities/canComment`.\n | - `canReadRevisions`: Deprecated. Use `capabilities/canReadRevisions`.\n- `capabilities/canRemoveChildren`: Use `capabilities/canDeleteChildren` or\n `capabilities/canTrashChildren`.\n\nChange resource\n---------------\n\nThe following new fields are available in the\n[`changes`](/workspace/drive/api/reference/rest/v3/changes) resource for a shared drive:\n\n- `changeType`: The change type. Possible values are `file` and `drive`.\n- `driveId`: The ID of the shared drive associated with this change.\n- `drive`: The updated state of the shared drive. Present if the `changeType` is `drive` and the user is still a member of the shared drive.\n\nAdditional changes might be required for applications that need to sync content\nwith shared drives or track activity. For details, see [Track changes for users\nand shared drives](/workspace/drive/api/guides/about-changes).\n\nRelated topics\n--------------\n\n- [Files and folders overview](/workspace/drive/api/guides/about-files)\n- [Changes and revisions overview](/workspace/drive/api/guides/change-overview)"]]