Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Support with_scopes and with_subject for GAE and GCE service accounts #310

@ducksauz

Description

@ducksauz

Is your feature request related to a problem? Please describe.
I'm building some tooling that is intended to run as a GAE cron job that will interact with our G Suite instance via the Admin API and domain wide delegation. In order for my code to interact with the Admin API, it needs to run scoped and with_subject to properly use the delegated access to G Suite. I want to do two-legged OAuth because it's a cron job and there's no opportunity for user interaction.

I can do it like this:

credentials = service_account.Credentials.from_service_account_file(
   'service-account.json',
   scopes=['https://www.googleapis.com/auth/admin.directory.user',
         'https://www.googleapis.com/auth/admin.directory.group'],
   subject='service-account@my-gsuite-domain.com')

and this works, but I don't want to have to deploy the service account private key file with the code artifacts to make it work.

Describe the solution you'd like

I'd rather have my code be able to just pull the service account info from GAE or GCE like this:

credentials = app_engine.Credentials(
   scopes=['https://www.googleapis.com/auth/admin.directory.user',
         'https://www.googleapis.com/auth/admin.directory.group'],
   subject='service-account@my-gsuite-domain.com')

or this:

credentials = compute_engine.Credentials(
   scopes=['https://www.googleapis.com/auth/admin.directory.user',
         'https://www.googleapis.com/auth/admin.directory.group'],
   subject='service-account@my-gsuite-domain.com')

Basically, please make all the domain wide delegation goodness in google.oauth2.service_account work in google.auth.app_engine and google.auth.compute_engine .

Describe alternatives you've considered
My current workaround to this will require me to deploy the GCP service account's private key with my code artifacts to GAE, which isn't great from a security perspective.

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.triage meI really want to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions