I have created, using a service account impersonating to test@test.com, a spreadsheet into test@test.com drive account. I need to this because the owner must be test@test.com. The problem is that when I want to share this spreadsheet the email notification is not been sent, although the permissions are granted. I am using the following code:
credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES, subject="test@test.com")
serviceDrive = googleapiclient.discovery.build('drive', 'v3', credentials=credentials)
body = {
'properties': {
'title': title,
},
'sheets': [{'properties': {'title': sheetName}} for sheetName in SHEETNAMES]
}
workSheet = serviceSheet.spreadsheets().create(body=body).execute()
spreadsheetId = workSheet['spreadsheetId']
user_permission = {
'type': 'user',
'role': emailrole,
'emailAddress': email
}
serviceDrive.permissions().create(fileId=spreadsheetId, emailMessage=message, body=user_permission, fields='id', sendNotificationEmail=True).execute()
Another problem that I have is couldnt invite an alias email, something like alias+alias@test.com, and recieve a message like "Bad Request. User message: "Sorry, an internal error has occurred and your request was not completed.""
Yesterday I was able to share and send notifications, impersonating test@test.com, an spreadsheet whose owner was the service account to another email only when the spreadsheet was shared with test@test.com. I guess this sentence is a bit confusing.