Hello all,
Since I wasn’t able to find anything in the FME documentation about this and despite reading hundreds of community posts, I wanted to share what I’ve learned about using the GoogleDriveConnector transformer to delete files in Google Drive Shared Drives and Shared Folders.
When using the GoogleDriveConnector in FME to delete files you need to make sure you have the right access. Shared Folders and Shared Drives have different types of access levels.
For Shared Folders you have "Editor", "Commenter", "Viewer". If you want to be able to "Delete" files from these folders you will have to have an "Editor" level access right to the folder and the files.
For Shared Drives, the access levels are "Manager", "Content Manager", "Contributor", "Commenter" and "Viewer".
Due to the restrictions on the Shared Drive, its folders, and the difference in the actions each access levels can have, if you want to delete files from a Folder in a Share Drive folder you will need to have "Manager" level access.
Here is a complete list of what each level access allows (from Google API Documentation):
When using the GoogleDriveConnector to delete files, FME uses a "DELETE" http call to the Google Drive API drive.delete method (at least that’s what I saw in my debug logs). In Google Drive API this "DELETE" request is for a permanent deletion of the file, this is how the Google API works (as per my understanding).
Google Drive however handles the files in a different way, when a user wants to delete files (via the google drive UI) they are not really deleted but “moved to the Trash” folder. The files are moved this Trash folder and automatically deleted by the system once a specific amount of time has passed, this is to allow the users to recover files in case the previous action was a mistake or because they need or want to recover a file.
Usually the access level given to anyone else other than the owner is "Content Manager" which will allow you the actions mentioned in the list above. But because the "Content Manager" is not “allowed” to permanently delete files (again based on the actions allowed from the list above), the "DELETE" request from the GoogleDriveConnector will not work. Again this is not a fault on any part, it's just how the two systems work (FME and Google API).
The way I see it there are 2 solutions for this issue:
1 - If the user accessing the Google Share Drive has “Content Manager” access level, then it needs to request “Manager” access level.
2 - If it is not possible to get an access level of “Manager” for the Shared Drive, then I suggest to use a HTTPCaller transformer. Configure it to use a POST method and to point the Request URL to the "Move to Trash" action from the Google API V2 (POST https://www.googleapis.com/drive/v2/files/{fileId}/trash ). The additional parameter “supporsAllDrives” needs to be added to the Query String Parameters in the HTTPCaller and set to “True”. Lastly, the Authentication needs to be set to Web Connection and your own web connection specified as well in the HTTPCaller transformer. By doing this we move the files to the Trash folder of the drive (which the Content Manager is allowed to do) and the system will take care of deleting the files automatically.