How to edit permission of a folder with Apps Script?

105 Views Asked by At

I have a shared Google Drive. I am making edits to the drive as the owner of the drive.

Is there a way in Apps Script to edit the permission of a folder by the folder's id and the email address of the user group I have to set permission for?

I came across this article in Apps Script documentation but the .setSharing() method appears to only apply to ANYONE, DOMAIN etc but not to a custom user group via its email.

1

There are 1 best solutions below

0
On

In your situation, how about the following sample script?

Sample script:

Before you use this script, please enable Drive API at Advanced Google services.

const folderId = "###"; // Please set your folder ID.
const groupEmail = "###"; // Please set your group email address.

Drive.Permissions.insert({ role: "writer", type: "group", value: groupEmail }, folderId, { supportsAllDrives: true });
  • When this script is run, when you have permission for the folder, the folder is shared with the group.
  • Please modify role: "writer" to your actual situation.

Reference: