AI-generated Key Takeaways
-
This 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.
-
The Looker Studio API has limited file management functionality compared to the Drive API, with only an equivalent endpoint for listing files (
Files: list
). -
While 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.
-
Despite differences in managing permissions, both APIs offer similar functionalities for updating permissions, with the exception of setting expiration times on Looker Studio permissions.
-
Developers 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.
This document outlines how to migrate code using the Drive API for permission management to the Looker Studio API. For common Drive API endpoints, it shows the corresponding Looker Studio API code.
Files
For the Drive API files endpoints, the Looker Studio API only has an equivalent
endpoint for the Files: list
endpoint.
List
API | Method | Endpoint |
---|---|---|
Drive | POST |
/drive/v3/files |
Looker Studio | GET |
/v1/assets:search |
Comparison:
Drive
const oAuthToken = '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
const oAuthToken = '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}`
}
})
See search assets.
Permissions
Create, Delete, And Get
API | Method | Endpoint |
---|---|---|
Drive | POST |
/drive/v3/files/fileId/permissions |
Drive | DELETE |
/drive/v3/files/fileId/permissions/permissionId |
Drive | GET |
/drive/v3/files/fileId/permissions/permissionId |
There are no corresponding endpoints in the Looker Studio API for managing
multiple Permissions
objects. There is only one permissions object for a
Looker Studio asset, and it always exists.
- To remove someone from an asset, see revoke all permissions
- To add someone to an asset, see add members
- To view a permissions object for an asset, see get permissions
List
There isn't a 1-to-1 match between Drive and Looker Studio, but the endpoints serve similar goals. The main difference is that a Drive file can have many permissions objects, and Looker Studio has exactly one.
API | Method | Endpoint |
---|---|---|
Drive | GET |
/drive/v3/files/fileId/permissions |
Looker Studio | GET |
/v1/assets/assetId/permissions |
Comparison:
Drive
This following code lists all the permissions objects for the Drive API. Depending on your code, you may call this method multiple times using pagination tokens (as shown) to ensure you can see all of the permissions that are set for a file.
const fileId = '123'; // This should be replaced with a valid Drive ID.
const oAuthToken = '123'; // This should be replaced with a valid OAuth token.
let nextPageToken = undefined;
let permissions = [];
do {
const permissionsData = await fetch(`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
Since there is only one permission object for a Looker Studio asset, you don't have to account for pagination.
const oAuthToken = '123' // This should be replaced with a valid OAuth token.
const assetId = '123' // This should be replaced with a valid asset ID.
fetch(`https://datastudio.googleapis.com/v1/assets/{ASSET_ID}/permissions`, {
headers: {
Authorization: `Bearer ${oAuthToken}`
}
}
See get permissions.
Update
For updating permissions, the Looker Studio and Drive APIs have very similar
functionality. The main difference is you cannot set an expirationTime
on a
Looker Studio permission.
API | Method | Endpoint |
---|---|---|
Drive | PATCH |
/drive/v3/files/fileId/permissions/permissionId |
Looker Studio | PATCH |
/v1/assets/assetId/permissions |
Comparison:
Drive
const fileId = '123'; // This should be replaced with a valid Drive ID.
const oAuthToken = '123'; // This should be replaced with a valid OAuth token.
const newPermissionsObject = {
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
const oAuthToken = '123' // This should be replaced with a valid OAuth token.
const assetId = '123' // This should be replaced with a valid asset ID.
const newPermissionsObject = {
permissions: {
//...
}
}
fetch(`https://datastudio.googleapis.com/v1/assets/${assetId}/permissions`, {
headers: {
Authorization: `Bearer ${oAuthToken}`
},
method: "PATCH",
body: JSON.stringify({
name: assetId,
permissions: newPermissionsObject
})
})
For use-case specific alternatives, see: