I am able to share a file with a given user by:
user_permission = ({
'type': 'user',
'role': 'writer',
'emailAddress': "example@gmail.com",
})
service.permissions().create(fileId=fileId,body=user_permission,fields='id').execute()
However, I don't know how to share the file with more than one user.
I have read the documentation in https://developers.google.com/drive/api/v3/reference/permissions/create, and I understand that for more than user the value of the "type" key specified in the body must be "group" instead of "user", but I don't find anywhere how the format of the parameter "emailAddress" should be in this case. I have proved with a list of strings of mails, a string of mails separated by commas or by spaces, but this has given me the following error:
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/drive/v3/files/1shxOQlNPqbXT-LwKTDvuwK0m-7IK43cDAWwxmnLgLvQ/permissions?fields=id&emailMessage=This+is+a+test&alt=json returned "The specified emailAddress is invalid or not applicable for the given permission type.". Details: "[{'domain': 'global', 'reason': 'invalid', 'message': 'The specified emailAddress is invalid or not applicable for the given permission type.', 'locationType': 'other', 'location': 'permission.emailAddress'}]">