Skip to content

Service account impersonation with --scopes doesn't work as documented #80

@SebastianMohrStade

Description

@SebastianMohrStade

The README's service account impersonation instructions don't work as documented due to a known limitation in Google's authentication libraries.

Problem:

gcloud auth application-default login \
  --impersonate-service-account=SERVICE_ACCOUNT_EMAIL \
  --scopes=https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform

The --scopes parameter is ignored when using impersonation with ADC. The generated token only contains cloud-platform scope, missing analytics.readonly.

Test to reproduce:

After running the README's impersonation command:

TOKEN=$(gcloud auth application-default print-access-token)
curl "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=$TOKEN"

Output shows only: "scope": "https://www.googleapis.com/auth/cloud-platform"
Missing: https://www.googleapis.com/auth/analytics.readonly
This causes 403 errors when the MCP server attempts Data API calls.

Root cause:
Google confirmed this is a limitation - scopes aren't stored in the ADC file format for impersonated service accounts. See: googleapis/google-auth-library-python#1204

</claude summary>

This was quite annoying to figure out, from the Issue discussion in the python lib, it is 'working as expected' and too much effort to fix. Therefore to spare future users of the MCP server please mention that in the readme.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions