Creates a new Access instance
Base URI for the access endpoint (typically set by Drive or DriveItem)
Grant access to a drive or drive item using role-based permissions
Creates permissions that allow the specified accessor to perform actions defined by the role on the resource.
Object specifying which entity to grant access to
The role to grant:
Optionaloptions: GrantAccessOptionsOptional grant options for cascade, path, or recursive modes
Promise resolving to the granted permission details
Grant editor role to an org user:
const drive = await client.drives.get({}, driveId);
await drive.access.grantByRole(
{ org_user: 'orguser123' },
'EDITOR'
);
Grant manager role with cascade to items:
const drive = await client.drives.get({}, driveId);
await drive.access.grantByRole(
{ org_user: 'orguser123' },
'MANAGER',
{ cascade_to_items: true }
);
Grant path-based access to a directory:
const item = await drive.items.get({}, itemId);
await item.access.grantByRole(
{ org_user: 'orguser123' },
'EDITOR',
{ mode: 'path', folder_role: 'READ_ONLY' }
);
Grant access to a drive or drive item (legacy action-based)
Promise resolving to the granted permission details
Use grantByRole instead for role-based access control Creates a permission that allows the specified accessor to perform the given action on the resource.
Revoke all access from a drive or drive item
Removes all permissions that were previously granted to the specified accessor on the resource. All permissions for the accessor are deactivated.
Promise resolving to the revocation details including revoked count
List all accessors and their roles for a drive or drive item
Retrieves all entities that have been granted access to the resource, along with their assigned roles and permission details.
Promise resolving to the list of accessors with their roles
List all accessors for a drive:
const drive = await client.drives.get({}, driveId);
const result = await drive.access.list();
console.log(`Drive has ${result.accessors.length} accessors`);
result.accessors.forEach(accessor => {
console.log(`${accessor.accessor_type}: ${accessor.accessor_id} - ${accessor.role}`);
});
Access control functions class for managing permissions on drives and drive items
This class provides methods for granting and revoking access to drives and drive items using role-based access control (RBAC). It handles both user and entity-based access control, supporting Users, OrgUsers, Agents, and Clients as accessors.
The class supports role-based permissions with different roles for different resource types:
Note: CONTRIBUTOR role is only valid for directories (folders), not files, as files don't support the create action. Use DriveDirectoryRole for directories and DriveFileRole for files.
The class also supports various grant modes including cascade, path-based, and recursive access.
The class is typically accessed through the Drive or DriveItem classes rather than instantiated directly.
Example
Access through Drive class (role-based):
Example
Access through DriveItem class (directory):
Example
Access through DriveItem class (file):