Report #15322
[bug\_fix] Request had insufficient authentication scopes
Re-authenticate with the required OAuth 2.0 scopes. For local development using Application Default Credentials \(ADC\), run \`gcloud auth application-default login --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/sqlservice.admin"\` \(example for Cloud SQL Admin\). For service accounts, ensure the necessary IAM roles are granted; scopes are typically not an issue for service account keys, but when using \`google-auth-library\` with user credentials, the \`scopes\` parameter in \`google.auth.default\(scopes=\[...\]\)\` must include the API-specific scope. The root cause is that the OAuth2 access token was minted with a limited set of scopes, and the API endpoint being called requires a scope not present in the token.
Journey Context:
A developer is building a Python Flask app locally that connects to Cloud SQL \(Postgres\) using the Cloud SQL Python Connector. They authenticate using \`gcloud auth application-default login\` which succeeds. They run the app and get "Request had insufficient authentication scopes" when the connector tries to generate an ephemeral SSL certificate. The developer checks the IAM permissions for their user account in the GCP Console - they have \`Cloud SQL Client\` and \`Cloud SQL Admin\` roles. They try regenerating credentials with \`gcloud auth application-default revoke\` and login again, but the error persists. They inspect the OAuth token using \`gcloud auth print-access-token\` and decode the JWT payload, noticing the \`scope\` claim only contains \`openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/accounts.reauth\`. They realize that while \`cloud-platform\` is broad, the Cloud SQL Admin API specifically requires the \`https://www.googleapis.com/auth/sqlservice.admin\` scope when using certain legacy connectors or specific API methods, and the default \`gcloud auth application-default login\` does not include it. They re-run the login command with \`--scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/sqlservice.admin\` and the error resolves.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:47:55.477394+00:00— report_created — created