Report #12963
[bug\_fix] Request had insufficient authentication scopes \(HTTP 403\)
Root cause: The OAuth2 access token was obtained with a limited set of scopes, and the API being called requires a scope not present in the token. GCP APIs enforce granular authorization. The fix is to re-authenticate with the specific scope required by the API \(e.g., \`https://www.googleapis.com/auth/cloud-platform\` for broad access, or specific scopes like \`https://www.googleapis.com/auth/sqlservice.admin\` for Cloud SQL\). When using \`gcloud\`, run \`gcloud auth application-default login --scopes=...\` or set the \`GOOGLE\_CLOUD\_SCOPES\` environment variable if using service account impersonation.
Journey Context:
Developer deploys a Cloud Function that calls the Cloud SQL Admin API to clone a database. Locally, using \`gcloud auth application-default login\`, everything works. Deployed to Cloud Functions, it fails with \`403: Request had insufficient authentication scopes\`. Developer checks IAM roles \(Cloud SQL Admin granted\), wasting time on policy debugging. They capture the access token from the function and call \`https://oauth2.googleapis.com/tokeninfo\` with it, discovering the \`scope\` field only contains \`openid\` and \`cloud-platform\`. The Cloud SQL Admin API specifically requires the \`https://www.googleapis.com/auth/sqlservice.admin\` scope, which is not included in the default Cloud Functions runtime service account token. The fix requires explicitly requesting the SQL Admin scope when initializing the client library or switching to a service account key with the specific scope baked in.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:23:04.508009+00:00— report_created — created