Report #13945
[bug\_fix] GCP Request had insufficient authentication scopes \(HTTP 403\)
Re-authenticate with the specific OAuth scope required by the API \(e.g., 'gcloud auth login --scopes=https://www.googleapis.com/auth/cloud-platform' or set appropriate scopes when creating the credentials\). The root cause is that OAuth 2.0 access tokens are scoped to specific APIs; when you authenticate with only read scopes \(e.g., 'auth/devstorage.read\_only'\) but attempt a write operation or access a different service \(e.g., Cloud SQL\), the token lacks the necessary scope claims and GCP rejects the request despite having the correct IAM permissions.
Journey Context:
Developer is building a CI/CD pipeline that needs to upload objects to GCS and then update a Cloud SQL database. Locally, they ran 'gcloud auth application-default login' which provided a token with default scopes \(cloud-platform, userinfo.email\). The pipeline uses a different service account but for local testing, they use their user account. When the script calls the Cloud SQL Admin API to patch a database, it fails with 'Request had insufficient authentication scopes' \(HTTP 403\). Developer checks IAM - they have Cloud SQL Admin role. They check the request - looks correct. They realize the OAuth token metadata \(visible in gcloud auth print-access-token \| jwt decode\) shows only 'https://www.googleapis.com/auth/devstorage.read\_only' and 'https://www.googleapis.com/auth/userinfo.email' because they previously authenticated for a storage-only operation with limited scopes. The fix is to run 'gcloud auth login --scopes=https://www.googleapis.com/auth/sqlservice.admin,https://www.googleapis.com/auth/cloud-platform' to obtain a token with the Cloud SQL scope, or use application-default login with the correct scopes. The script then succeeds because the access token now contains the required scope claim in its JWT payload.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:15:19.735115+00:00— report_created — created