Cannot set sharing expiration date on shared drive folder

I have made a little web tool that is supposed to allow setting expiration dates on shared items in shared drives. As listed in https://workspaceupdates.googleblog.com/2023/05/set-expirations-for-files-in-shared-google-drives.ht... these expirations can be set through the drive API but not by the normal user interface.

The tool works perfectly on a personal drive and allows you to set expiration dates on both files and folders. In a shared drive, it works to set expiration dates on a shared file (which a user could not normally do). However, when I try to set expiring permissions on a shared folder in a shared drive, it gives "403, Expiration dates cannot be set on this item." For some reason it works to set in personal drives but not the shared drive. It says at https://support.google.com/a/users/answer/13005112?hl=en&visit_id=638290086218645992-2257566443&rd=1... that "For folders, you can set expiration dates for viewers and commenters" but this does not work.

How can I accomplish this?

Main part of code I am using:

 

 

let params = {
	supportsAllDrives: true,
};
let body = {
	role: newP.role
}
if (newP.newDate == null) {
	params.removeExpiration = true;
	body.expirationTime = null;
} else {
	body.expirationTime = newP.newDate;
}
gapi.client.request({
	path: `https://www.googleapis.com/drive/v3/files/${fileId}/permissions/${newP.id}`,
	params,
	body,
	method: "PATCH"

})

 

 

 

0 4 2,138
4 REPLIES 4

On the page you mentioned in your second URL, it says (emphasis mine):

To set an expiration date for files in shared drives, you must use the Drive API

So maybe Shared Drives don't support expiration dates for shared folders?

@icrew As it says, you must use the Drive API to set it for files. It doesn't list any such restrictions about folders, although personal experience (via the ui) says otherwise. 

So it says:

"For files, you can add an expiration date for..."

"For folders, you can set expiration dates for..."

And further states that on Shared Drives you must use the API to set it on files. There's no mention of special requirements for folders in shared drives.

Anyways, that section seems to be using the term file to include folders, as shown by the sentence "For files in My Drive, you can set an expiration date to limit or end access to that file in the file sharing flow". Then it lists what happens when you set it on a folder. Therefore, that sentence refers to both files and folders when it says 'files'. Then it later says you can set it on "file" in the shared drive, which would likely be using the same definition.

So it should still work, right??

Anyone have a solution for this?

Does anyone have a solution for this? Setting an expiration on folders within a Shared Drive would be really helpful.

Top Solution Authors