2

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.

Diego Silvera
  • 201
  • 1
  • 2
  • 13
  • 1
    Service account share notification is broken last i checked unless you are using impersonation in which case the notification should be coming from the person you are impersonating but that requires that you have set up domain wide delegation on a gsuite domain. – Linda Lawton - DaImTo Dec 16 '20 at 17:38
  • @DaImTo Yes have set up domain wide delegation properly, because I can create spreadsheets into test@test.com impersonating that account. Did you know if this is a reported bug? What about alias emails? – Diego Silvera Dec 16 '20 at 17:55
  • @DaImTo are you talking about this https://stackoverflow.com/questions/62025965/sendnotificationemail-doesnt-work-with-service-account-drive-api-v3 or this https://stackoverflow.com/questions/61873497/is-google-drive-api-broken-i-cant-make-it-to-send-email-notification – Diego Silvera Dec 16 '20 at 18:52
  • this https://stackoverflow.com/a/21372067/1841839 or maybe this https://developers.google.com/admin-sdk/directory/v1/guides/delegation – Linda Lawton - DaImTo Dec 16 '20 at 18:58

0 Answers0