python-samples icon indicating copy to clipboard operation
python-samples copied to clipboard

Using service account with domain-wide delegation still causing error "Precondition check failed"

Open jackred8 opened this issue 3 years ago • 0 comments

Summary

If using a service account with domain-wide authority delegation, run this python sample code with userId=me or any email address within the organization, it will return an error:

{'message': 'Precondition check failed.', 'domain': 'global', 'reason': 'failedPrecondition'}

Expected Behavior

Service account with correct scopes should be able to access any userIds

Actual Behavior

Service account with correct scopes always gets error

{'message': 'Precondition check failed.', 'domain': 'global', 'reason': 'failedPrecondition'}

Steps to Reproduce the Problem

Follow the instructions here https://developers.google.com/admin-sdk/directory/v1/guides/delegation#python

  1. Create the service account and credentials
  2. Delegate domain-wide authority to your service account
  3. Assign the correct scopes according to here https://developers.google.com/gmail/api/reference/rest/v1/users.settings.sendAs/list
  4. Run the code from here https://github.com/googleworkspace/python-samples/blob/master/gmail/snippet/settings%20snippets/update_signature.py

Specifications

  • Python 3.7.3
  • macOS Monterey Version 12.3.1

jackred8 avatar Jul 08 '22 04:07 jackred8