Report #77826
[bug\_fix] Request had insufficient authentication scopes. \(HTTP 403\)
Explicitly request the specific OAuth scope required by the API \(e.g., 'https://www.googleapis.com/auth/spreadsheets'\) when initializing the client or ADC. If using GCE/Cloud Run, ensure the instance has the 'https://www.googleapis.com/auth/cloud-platform' scope or the specific scope in the service account access scopes. Root cause: OAuth 2.0 tokens are scoped to specific APIs. The 'cloud-platform' scope is wide, but APIs like Google Sheets or Drive require explicit scopes that are not included by default in GCE metadata server tokens unless explicitly requested at VM creation time or via the \`scopes\` parameter in the client library.
Journey Context:
A developer deploys a Cloud Function that reads from Google Sheets. Locally, using user credentials \('gcloud auth'\), it works. When deployed, it fails with 'insufficient authentication scopes' even though the service account has 'Editor' IAM role. The developer checks the Cloud Function's service account, it has 'cloud-platform' OAuth scope granted by default, but the Sheets API requires the 'spreadsheets' scope. Realizing that 'google.auth.default\(\)' by default only requests 'cloud-platform' scope if running as service account, but Sheets API needs 'drive' or 'spreadsheets' scope, they modify the code to explicitly pass \`scopes=\['https://www.googleapis.com/auth/spreadsheets'\]\` to \`google.auth.default\(\)\`. After redeploying with the explicit scope, the function succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:13:45.893224+00:00— report_created — created