Reputation: 33
I'm trying to do a small application that reads a shared folder with different users of my organization, get the files and then delete them.
The problem is that I can't delete the file of a different user, because I can only delete files of my ownership (receiving a 403 Insufficient permissions for this file)
Another solution I found is change the owner of the file, but I get the same error.
I test it with a Native Application oAuth with a SuperAdmin account of the organization and with a service account, and none of them works.
A piece of my code trying to change the ownership:
new_permission = {
'value': "[email protected]",
'type': "user",
'role': "writer"
}
perm = drive_service.permissions().insert(fileId=idfield, body=new_permission).execute()
perm['role'] = 'owner'
drive_service.permissions().update(fileId=idfield, permissionId=perm['id'], transferOwnership=True, body=perm).execute()
I spend hours searching and trying different solutions I found, but no one works (for example, Transfer ownership of a file fails - even as Super Administrator (Google Drive API, Java)).
Somebody has some idea? Thanks!
Upvotes: 3
Views: 2859
Reputation: 12673
The best solution right now involves two steps:
The email address of the owner is required to use delegated authorization, but isn't always visible in the permissions objects returned by the API. The email address will be visible if either:
Upvotes: 1