Im tryng to make an app in python 3.7 that list all the files in a drive account, and set the public files to private. I am using the google drive api v3. To do this i need to change the file permissions "type" to "user", this didint work, and now im tryng first to put the file permissions "role" to "owner", because on the public files it shows "reader" or "writer".
I tried a lot of things and it doesent works.
Here is the code (its in spanish, because its my language. the function that is not working is called "ActualizarPermisos")
def actualizarPermisos(service, file_id, permission_id):
try:
# First retrieve the permission from the API.
permission = service.permissions().get(
fileId=file_id, permissionId=permission_id).execute()
permission['role'] = 'writer'
return service.permissions().update(
fileId=file_id, permissionId=permission_id, body=permission, transferOwnership=False).execute()
except errors.HttpError as error:
print ('An error occurred: %s' % error)
return None
The error that shows is: "An error occurred: https://www.googleapis.com/drive/v3/files/0B4SorsEEhamLfmVuQUtFUXpMS25RT2k2SkpOTzFhclRubk1VM3ZDUkw5b3o0Zm5kRWpHWjQ/permissions/anyone?transferOwnership=false&alt=json returned "The resource body includes fields which are not directly writable."> "