Method: permissions.insert
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
ファイルまたは共有ドライブの権限を挿入します。
警告: 同じファイルに対する権限の同時操作はサポートされていません。最後に更新された内容のみが適用されます。
HTTP リクエスト
POST https://www.googleapis.com/drive/v2/files/{fileId}/permissions
この URL は gRPC Transcoding 構文を使用します。
パスパラメータ
パラメータ |
fileId |
string
ファイルまたは共有ドライブの ID。
|
クエリ パラメータ
パラメータ |
emailMessage |
string
通知メールに含める書式なしのカスタム メッセージ。
|
enforceSingleParent (deprecated) |
boolean
非推奨: 詳細については、moveToNewOwnersRoot をご覧ください。
|
moveToNewOwnersRoot |
boolean
このパラメータが有効になるのは、アイテムが共有ドライブになく、リクエストでアイテムの所有権を移行しようとしている場合のみです。true に設定すると、アイテムは新しいオーナーのマイドライブのルートフォルダに移動され、以前の親フォルダはすべて削除されます。false に設定した場合、親は変更されません。
|
sendNotificationEmails |
boolean
ユーザーまたはグループと共有するときに通知メールを送信するかどうか。このパラメータは無視され、role が owner の場合にメールが送信されます。
|
supportsAllDrives |
boolean
リクエスト元のアプリケーションがマイドライブと共有ドライブの両方をサポートしているかどうか。
|
supportsTeamDrives (deprecated) |
boolean
非推奨: 代わりに、supportsAllDrives を使用してください。
|
useDomainAdminAccess |
boolean
ドメイン管理者としてリクエストを送信します。true に設定すると、ファイル ID パラメータが共有ドライブを参照し、リクエスト元が共有ドライブが属するドメインの管理者である場合、リクエスト元にアクセス権が付与されます。
|
enforceExpansiveAccess |
boolean
リクエストで広範なアクセス ルールを適用するかどうか。
|
リクエストの本文
リクエストの本文には Permission
のインスタンスが含まれます。
レスポンスの本文
成功した場合、レスポンスの本文には、新しく作成された Permission
のインスタンスが含まれます。
認可スコープ
以下のいずれかの OAuth スコープが必要です。
https://www.googleapis.com/auth/docs
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
一部のスコープは制限されており、アプリで使用するにはセキュリティ評価が必要です。詳しくは、認可ガイドをご覧ください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-25 UTC。
[null,null,["最終更新日 2025-07-25 UTC。"],[],[],null,["# Method: permissions.insert\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nInserts a permission for a file or shared drive.\n\n**Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied.\n\n### HTTP request\n\n`POST https://www.googleapis.com/drive/v2/files/{fileId}/permissions`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|-----------------------------------------------|\n| `fileId` | `string` The ID for the file or shared drive. |\n\n### Query parameters\n\n| Parameters ||\n|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `emailMessage` | `string` A plain text custom message to include in notification emails. |\n| `enforceSingleParent` **(deprecated)** | `boolean` Deprecated: See `moveToNewOwnersRoot` for details. |\n| `moveToNewOwnersRoot` | `boolean` This parameter will only take effect if the item is not in a shared drive and the request is attempting to transfer the ownership of the item. If set to `true`, the item will be moved to the new owner's My Drive root folder and all prior parents removed. If set to `false`, parents are not changed. |\n| `sendNotificationEmails` | `boolean` Whether to send notification emails when sharing to users or groups. This parameter is ignored and an email is sent if the `role` is `owner`. |\n| `supportsAllDrives` | `boolean` Whether the requesting application supports both My Drives and shared drives. |\n| `supportsTeamDrives` **(deprecated)** | `boolean` Deprecated: Use `supportsAllDrives` instead. |\n| `useDomainAdminAccess` | `boolean` Issue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs. |\n| `enforceExpansiveAccess` | `boolean` Whether the request should enforce expansive access rules. |\n\n### Request body\n\nThe request body contains an instance of [Permission](/workspace/drive/api/reference/rest/v2/permissions#Permission).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Permission](/workspace/drive/api/reference/rest/v2/permissions#Permission).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/docs`\n- `\n https://www.googleapis.com/auth/drive`\n- `\n https://www.googleapis.com/auth/drive.file`\n\nSome scopes are restricted and require a security assessment for your app to use them. For more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]