Re: gam all users print delegates returns "Gmail API Service/App not enabled" — 401 Unauthorized on Service Account token request despite correct DWD scopes

88 views
Skip to first unread message

Christian Gonzalez Villaseñor

unread,
Jul 15, 2026, 3:18:16 PM (3 days ago) Jul 15
to GAM for Google Workspace

My Goal is:

I'm trying to generate a full Gmail delegates audit report for my Google Workspace domain using:

gam all users print delegates > delegates_report.csv

The goal is to get a CSV with all users and their configured Gmail delegates (delegateAddress, delegationStatus) for compliance/audit purposes.


On Wed, Jul 15, 2026 at 12:42 PM Christian Gonzalez Villaseñor <chris...@backbase.com> wrote:

Hi GAM community,

I'm running GAM 7.46.01 on macOS (arm64) and hitting a wall with print delegates. I've done extensive debugging and can't figure out what's missing. Here's everything I know:

The command:

gam all users print delegates

The error:

User: ad...@company.com, Gmail API Service/App not enabled

This happens for all users in the domain, including my own admin account.


What works:

  • gam print users ✅ — lists all users correctly

  • gam user ad...@company.com show drivefileacl root ✅ — DWD works for Drive

  • OAuth2 token is valid and correctly authenticated

What doesn't work:

  • Any Gmail command via DWD/Service Account impersonation


Debug output (debug_level 4):

The Service Account successfully connects to admin.googleapis.com and gmail.googleapis.com for discovery, but then fails at the token request:

POST oauth2.googleapis.com/token cred-type/sa reply: HTTP/1.1 401 Unauthorized

Current DWD scopes for the Service Account Client ID:


GCP Project setup:

  • Gmail API: enabled in the project

  • OAuth app: configured as Internal

  • Service Account is trusted and API block-exempt in Admin Console → Security → API Controls → App Access Control


What I've already ruled out:

  • ❌ Wrong Client ID — confirmed it matches between oauth2service.json and DWD entry

  • ❌ OAuth token expired — gam oauth info shows valid token

  • ❌ App Access Control blocking — Service Account is explicitly trusted

  • ❌ Gmail disabled at domain level — Gmail is enabled for all users

  • ❌ Missing Gmail scopes — mail.google.com/, gmail.settings.basic, and gmail.settings.sharing are all present in DWD

The 401 happens specifically when the Service Account tries to impersonate a user for Gmail — Drive impersonation works fine with the same Service Account and DWD setup.

Any ideas on what could cause Gmail impersonation to fail via DWD while Drive works perfectly?

Thanks in advance!

Christian Gonzalez Villaseñor

unread,
Jul 15, 2026, 3:18:26 PM (3 days ago) Jul 15
to GAM for Google Workspace

Ross Scroggs

unread,
Jul 15, 2026, 3:21:18 PM (3 days ago) Jul 15
to google-ap...@googlegroups.com
Have you done: gam user some...@yourdomain.com update serviceaccount\

Replace some...@yourdomain.com with a valid address in your domain

Ross
----
Ross Scroggs



--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-manager/ae6308d5-0f31-45b5-b357-025de931c257n%40googlegroups.com.

Christian Gonzalez Villaseñor

unread,
Jul 15, 2026, 5:01:15 PM (3 days ago) Jul 15
to google-ap...@googlegroups.com

Hi Ross,

I'm getting the error "Gmail API Service/App not enabled" when running GAM commands like (gam all users print delegates) against a user's Gmail account.

For context:

Is this error typically caused by something beyond the OAuth scopes? Could it be a Gmail API enablement issue at the Google Cloud project level, or something else you've seen before?

Any guidance would be appreciated. Thanks!


Christian Gonzalez Villaseñor

unread,
Jul 15, 2026, 5:04:42 PM (3 days ago) Jul 15
to GAM for Google Workspace

Hi Ross,

I'm getting the error "Gmail API Service/App not enabled" when running GAM commands like (gam all users print delegates) against a user's Gmail account.

For context:

Is this error typically caused by something beyond the OAuth scopes? Could it be a Gmail API enablement issue at the Google Cloud project level, or something else you've seen before?

Any guidance would be appreciated. Thanks!


Jay Lee

unread,
Jul 15, 2026, 5:06:44 PM (3 days ago) Jul 15
to google-ap...@googlegroups.com
Run Ross' command and show the output.


Jay Lee

Ross Scroggs

unread,
Jul 15, 2026, 8:24:36 PM (3 days ago) Jul 15
to google-ap...@googlegroups.com
Christian,

I'm in California (GMT-7), send me a Meet/Zoom invitation between 07:30AM and 06:00PM and I'll help figure out what's going on.

Ross
----
Ross Scroggs


Reply all
Reply to author
Forward
0 new messages