Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jackred8 opened this issue Jul 8, 2022 · 0 comments · May be fixed by #337
Open
Assignees

Comments

@jackred8
Copy link

jackred8 commented Jul 8, 2022

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 added a commit to jackred8/python-samples that referenced this issue Jul 8, 2022
If you have delegated domain-wide access to the service account and you want to impersonate a user account, use the with_subject method of an existing ServiceAccountCredentials object.
@jackred8 jackred8 linked a pull request Jul 8, 2022 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants