Ajay Bhosale
Ajay Bhosale

Reputation: 2002

Setting a role as fileOrganizer for shared/team google drive item failing for shared/team drive

Trying to set permission as "fileOrganizer" for a user on a shared google drive folder, but the v3 (and v2) API giving error FileOrganizer role is only valid for shared drives, and I could NOT find a way to specify that the folder is on a shared drive.

It is possible to set same permission via UI.

Code

gapi.client.drive.permissions
      .create({
        fileId: folderId,
        sendNotificationEmail: false,
        supportsAllDrives: true,
        role: 'fileOrganizer' // 'writer' works
        type: 'user',
        emailAddress
      }).then(

API Response

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "fileOrganizerOnNonTeamDriveNotSupported",
    "message": "FileOrganizer role is only valid for shared drives."
   }
  ],
  "code": 403,
  "message": "FileOrganizer role is only valid for shared drives."
 }
}

Points to note

  1. For a shared drive, some API documents requires setting "supportsAllDrives" parameter to true, but API document indicates it as deprecated.
  2. This document explains Specific roles for shared drives, but there is no way to mention that permissions.create request is for a shared drive.
  3. files.list API has option to pass driveId by setting 'corpora': 'drive' which indicates a shared drive, but similar option is not available for permissions.create.

I tried various combinations like passing driveId without any luck. Are there any other options?

Upvotes: 2

Views: 2272

Answers (1)

ziganotschka
ziganotschka

Reputation: 26796

The role fileOrganizer is only a valid choice for the whole shared drive rather than a single file on this drive

What you can do instead:

  • Either give the user the role fileOrganizer for the whole drive (specifying the shared Drive Id as file Id)
  • Or give the user permission for the specific file, specifying writer, reader, commenter or owner (for the latter case specifying transferOwnership true) as role.

Upvotes: 1

Related Questions