このドキュメントでは、権限用の Drive API を使用してコードを移行する方法について説明します。
Looker Studio API です。一般的な Drive API エンドポイントの場合、
対応する Looker Studio API コードです
ファイル
Drive API ファイルのエンドポイントについては、Looker Studio API には同等のものしかありません。
Files: list エンドポイントのエンドポイント。
リスト
API
メソッド
エンドポイント
ドライブ
POST
/drive/v3/files
Looker Studio
GET
/v1/assets:search
比較:
ドライブ
constoAuthToken='123'// This should be replaced with a valid OAuth token.fetch(`https://www.googleapis.com/drive/v3/files`,{headers:{Authorization:`Bearer ${oAuthToken}`},method:"POST",})
Looker Studio
constoAuthToken='123'// This should be replaced with a valid OAuth token.fetch(`https://datastudio.googleapis.com/v1/assets:search?assetTypes={ASSET_TYPE}`,{headers:{Authorization:`Bearer ${oAuthToken}`}})
ドライブと Looker Studio は 1 対 1 で一致しませんが、エンドポイントは
同様の目標を設定することです主な違いは、1 つのドライブのファイルには複数の
権限オブジェクトが 1 つで、Looker Studio には 1 つだけあります。
API
メソッド
エンドポイント
ドライブ
GET
/drive/v3/files/fileId/permissions
Looker Studio
GET
/v1/assets/assetId/permissions
比較:
ドライブ
次のコードは、Drive API のすべての権限オブジェクトを一覧表示します。
コードによっては、ファイルに設定されているすべての権限を表示するために、ページ設定トークンを使用してこのメソッドを複数回呼び出さなければならない場合もあります(以下を参照)。
constfileId='123';// This should be replaced with a valid Drive ID.constoAuthToken='123';// This should be replaced with a valid OAuth token.letnextPageToken=undefined;letpermissions=[];do{constpermissionsData=awaitfetch(`https://www.googleapis.com/drive/v3/files/${fileId}/permissions`,{headers:{Authorization:`Bearer ${oAuthToken}`}});nextPageToken=permissionsData.nextPageToken;permissions=permissions.concat(permissionsData.permissions)}while(nextPageToken!==undefined);
Looker Studio
Looker Studio アセットには権限オブジェクトが 1 つしかないため、権限オブジェクトは
ページ分けを考慮する必要があります
constoAuthToken='123'// This should be replaced with a valid OAuth token.constassetId='123'// This should be replaced with a valid asset ID.fetch(`https://datastudio.googleapis.com/v1/assets/{ASSET_ID}/permissions`,{headers:{Authorization:`Bearer ${oAuthToken}`}}
権限の更新に関しては、Looker Studio と Drive API はよく似ています。
説明します。主な違いは、expirationTime を
Looker Studio の権限。
API
メソッド
エンドポイント
ドライブ
PATCH
/drive/v3/files/fileId/permissions/permissionId
Looker Studio
PATCH
/v1/assets/assetId/permissions
比較:
ドライブ
constfileId='123';// This should be replaced with a valid Drive ID.constoAuthToken='123';// This should be replaced with a valid OAuth token.constnewPermissionsObject={expirationTime:'...',role:'owner',// Or any other option}fetch(`https://www.googleapis.com/drive/v3/files/${fileId}/permissions/permissionId`,{headers:{Authorization:`Bearer ${oAuthToken}`},method:"PATCH",body:JSON.stringify(newPermissionsObject)})
Looker Studio
constoAuthToken='123'// This should be replaced with a valid OAuth token.constassetId='123'// This should be replaced with a valid asset ID.constnewPermissionsObject={permissions:{//...}}fetch(`https://datastudio.googleapis.com/v1/assets/${assetId}/permissions`,{headers:{Authorization:`Bearer ${oAuthToken}`},method:"PATCH",body:JSON.stringify({name:assetId,permissions:newPermissionsObject})})
[null,null,["最終更新日 2025-07-25 UTC。"],[[["\u003cp\u003eThis guide explains how to migrate code using the Drive API for permission management to the Looker Studio API, providing equivalent Looker Studio API code snippets for common Drive API endpoints.\u003c/p\u003e\n"],["\u003cp\u003eThe Looker Studio API has limited file management functionality compared to the Drive API, with only an equivalent endpoint for listing files (\u003ccode\u003eFiles: list\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eWhile the Drive API allows managing multiple permission objects per file, Looker Studio assets have a single, always-existing permission object, leading to different endpoint usage for permission control.\u003c/p\u003e\n"],["\u003cp\u003eDespite differences in managing permissions, both APIs offer similar functionalities for updating permissions, with the exception of setting expiration times on Looker Studio permissions.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers should use appropriate HTTP libraries for their chosen language when making calls to the Looker Studio API, as there are no dedicated client libraries available.\u003c/p\u003e\n"]]],[],null,["# Migrating from the Drive API\n\nThis document outlines how to migrate code using the Drive API for permission\nmanagement to the Looker Studio API. For common Drive API endpoints, it shows\nthe corresponding Looker Studio API code.\n| **Note:** There are no client libraries for using the Looker Studio API. To make these calls, use an appropriate HTTP library for your language.\n\nFiles\n-----\n\nFor the Drive API files endpoints, the Looker Studio API only has an equivalent\nendpoint for the `Files: list` endpoint.\n\n### List\n\n| API | Method | Endpoint |\n|---------------|--------|---------------------|\n| Drive | `POST` | `/drive/v3/files` |\n| Looker Studio | `GET` | `/v1/assets:search` |\n\nComparison:\n\n**Drive** \n\n const oAuthToken = '123' // This should be replaced with a valid OAuth token.\n fetch(`https://www.googleapis.com/drive/v3/files`, {\n headers: {\n Authorization: `Bearer ${oAuthToken}`\n },\n method: \"POST\",\n })\n\n**Looker Studio** \n\n const oAuthToken = '123' // This should be replaced with a valid OAuth token.\n fetch(`https://datastudio.googleapis.com/v1/assets:search?assetTypes={ASSET_TYPE}`, {\n headers: {\n Authorization: `Bearer ${oAuthToken}`\n }\n })\n\nSee [search assets](/looker-studio/integrate/api/reference/assets/search).\n\nPermissions\n-----------\n\n### Create, Delete, And Get\n\n| API | Method | Endpoint |\n|-------|----------|---------------------------------------------------|\n| Drive | `POST` | `/drive/v3/files/fileId/permissions` |\n| Drive | `DELETE` | `/drive/v3/files/fileId/permissions/permissionId` |\n| Drive | `GET` | `/drive/v3/files/fileId/permissions/permissionId` |\n\nThere are no corresponding endpoints in the Looker Studio API for managing\nmultiple `Permissions` objects. There is only one permissions object for a\nLooker Studio asset, and it always exists.\n\n- To remove someone from an asset, see [revoke all permissions](/looker-studio/integrate/api/reference/permissions/revokeAllPermissions)\n- To add someone to an asset, see [add members](/looker-studio/integrate/api/reference/permissions/addMembers)\n- To view a permissions object for an asset, see [get permissions](/looker-studio/integrate/api/reference/permissions/get)\n\n### List\n\nThere isn't a 1-to-1 match between Drive and Looker Studio, but the endpoints\nserve similar goals. The main difference is that a Drive file can have many\npermissions objects, and Looker Studio has exactly one.\n\n| API | Method | Endpoint |\n|---------------|--------|--------------------------------------|\n| Drive | `GET` | `/drive/v3/files/fileId/permissions` |\n| Looker Studio | `GET` | `/v1/assets/assetId/permissions` |\n\nComparison:\n\n**Drive**\n\nThis following code lists all the permissions objects for the Drive API.\nDepending on your code, you may call this method multiple times using pagination\ntokens (as shown) to ensure you can see all of the permissions that are set for\na file. \n\n const fileId = '123'; // This should be replaced with a valid Drive ID.\n const oAuthToken = '123'; // This should be replaced with a valid OAuth token.\n let nextPageToken = undefined;\n let permissions = [];\n do {\n const permissionsData = await fetch(`https://www.googleapis.com/drive/v3/files/${fileId}/permissions`, {\n headers: {\n Authorization: `Bearer ${oAuthToken}`\n }\n });\n nextPageToken = permissionsData.nextPageToken;\n permissions = permissions.concat(permissionsData.permissions)\n } while (nextPageToken !== undefined);\n\n**Looker Studio**\n\nSince there is only one permission object for a Looker Studio asset, you don't\nhave to account for pagination. \n\n const oAuthToken = '123' // This should be replaced with a valid OAuth token.\n const assetId = '123' // This should be replaced with a valid asset ID.\n fetch(`https://datastudio.googleapis.com/v1/assets/{ASSET_ID}/permissions`, {\n headers: {\n Authorization: `Bearer ${oAuthToken}`\n }\n }\n\nSee [get permissions](/looker-studio/integrate/api/reference/permissions/get).\n\nUpdate\n------\n\nFor updating permissions, the Looker Studio and Drive APIs have very similar\nfunctionality. The main difference is you cannot set an `expirationTime` on a\nLooker Studio permission.\n\n| API | Method | Endpoint |\n|---------------|---------|---------------------------------------------------|\n| Drive | `PATCH` | `/drive/v3/files/fileId/permissions/permissionId` |\n| Looker Studio | `PATCH` | `/v1/assets/assetId/permissions` |\n\nComparison:\n\n**Drive** \n\n const fileId = '123'; // This should be replaced with a valid Drive ID.\n const oAuthToken = '123'; // This should be replaced with a valid OAuth token.\n const newPermissionsObject = {\n expirationTime: '...',\n role: 'owner', // Or any other option\n }\n fetch(`https://www.googleapis.com/drive/v3/files/${fileId}/permissions/permissionId`, {\n headers: {\n Authorization: `Bearer ${oAuthToken}`\n },\n method: \"PATCH\",\n body: JSON.stringify(newPermissionsObject)\n })\n\n**Looker Studio** \n\n const oAuthToken = '123' // This should be replaced with a valid OAuth token.\n const assetId = '123' // This should be replaced with a valid asset ID.\n const newPermissionsObject = {\n permissions: {\n //...\n }\n }\n\n fetch(`https://datastudio.googleapis.com/v1/assets/${assetId}/permissions`, {\n headers: {\n Authorization: `Bearer ${oAuthToken}`\n },\n method: \"PATCH\",\n body: JSON.stringify({\n name: assetId,\n permissions: newPermissionsObject\n })\n })\n\nFor use-case specific alternatives, see:\n\n- [add members](/looker-studio/integrate/api/reference/permissions/addMembers)\n- [revoke all permissions](/looker-studio/integrate/api/reference/permissions/revokeAllPermissions)"]]