Google Drive - Update File Permission
@sergio
code:
data:privatelast updated:4 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 1,000,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
googledrive_update_file_permission
Updates a file permission with patch semantics.
auth
(auths.google_drive)
params
Role

The role granted by this permission. While new values may be supported in the future, the following are currently allowed:

  • owner
  • organizer
  • fileOrganizer
  • writer
  • commenter
  • reader
string ·params.role
FileId

The ID of the file or shared drive.

 
string ·params.fileId
PermissionId

The ID of the permission.

 
string ·params.permissionId
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
}
39
//See the API docs here: https://developers.google.com/drive/api/v3/reference/permissions/update?authuser=2
const data = {
  allowFileDiscovery: params.allowFileDiscovery,
  deleted: params.deleted,
  displayName: params.displayName,
  domain: params.domain,
  emailAddress: params.emailAddress,
  expirationTime: params.expirationTime,  
  permissionDetails: typeof params.permissionDetails == 'undefined' ? params.permissionDetails : JSON.parse(params.permissionDetails),  
  photoLink: params.photoLink,
  role: params.role,
  teamDrivePermissionDetails: typeof params.teamDrivePermissionDetails == 'undefined' ? params.teamDrivePermissionDetails : JSON.parse(params.teamDrivePermissionDetails),  
  type: params.type,
}
const config = {
  method: "patch",
  url: `https://www.googleapis.com/drive/v3/files/${params.fileId}/permissions/${params.permissionId}`,
  params: {
    removeExpiration: params.removeExpiration,
    supportsAllDrives: params.supportsAllDrives,
    supportsTeamDrives: params.supportsTeamDrives,
    transferOwnership: params.transferOwnership,
    useDomainAdminAccess: params.useDomainAdminAccess,
    alt: params.alt,
    fields: params.fields || "*", //For improved performance, select actual fields from the related entity required for your use case. "*" selects all fields.
    key: params.key,
    oauth_token: params.oauth_token,
    prettyPrint: params.prettyPrint,
    quotaUser: params.quotaUser,
    userIp: params.userIp,
  },
  headers: {
    Authorization: `Bearer ${auths.google_drive.oauth_access_token}`,
  },
  data,
}
return await require("@pipedreamhq/platform").axios(this, config)