When Cloud & Workspace displays PERMISSION_DENIED: 403 error, When calling Google Sheets API, Drive API, or GCP REST endpoints using a Service Account or OAuth token, HTTP 403 PERMISSION_DENIED means authentication succeeded, but the identity lacks IAM/file-level access or requested an insufficient read-only OAuth scope.
Step-by-Step Resolution
- When using a GCP Service Account (.json key or Workload Identity) with Google Sheets or Drive, copy the service account email (*@*.iam.gserviceaccount.com) and explicitly Share the target spreadsheet or Shared Drive folder with it as Editor or Viewer.
- Check that both Google Sheets API and Google Drive API are enabled inside Google Cloud Console > APIs & Services > Enabled APIs & Services.
- Verify your OAuth scope matches the action: writing cells requires https://www.googleapis.com/auth/spreadsheets, not spreadsheets.readonly.
- In Google Workspace domains, check Admin Console > Security > Access and data control > API controls to ensure Drive SDK and API access are not blocked for the OU.
Common Edge Cases
If authenticating locally via gcloud auth application-default login vs a Service Account env var (GOOGLE_APPLICATION_CREDENTIALS), the code may accidentally send a developer credential that lacks Shared Drive access.
When This Doesn't Work
Test a minimal GET call using OAuth 2.0 Playground with the exact access token to confirm whether the failure comes from the OAuth token scopes or file sharing permissions.
Prevention Tips
Use Google Groups or Shared Drives for team automation access and keep spreadsheet sharing permissions synchronized via Infrastructure-as-Code or documented setup checklists.
Relevant Tools & Guides
- Google Cloud (GCP) Pricing Estimator — Estimate monthly infrastructure bills for Compute Engine VMs, Cloud Storage GB, Cloud SQL, and network egress bandwidth.
- JSON Formatter & Validator — Format, beautify, inspect syntax errors, and minify JSON payloads.
- Read Google Cloud IAM Best Practices: Enforcing Least Privilege, Custom Roles & Service Accounts →
- Read How to Sync BigQuery to Google Sheets Automatically for Real-Time Reports →
Related Errors
Frequently Asked Questions
Why do Service Accounts get 403 even with Owner IAM role on the GCP project?
GCP project IAM controls Cloud resources (BigQuery, Storage), NOT personal/Workspace Google Drive files. Every Drive file or Sheet must be explicitly shared with the service account email.
Does sharing a parent folder give a Service Account access to files inside?
Yes, sharing a Google Drive folder or adding the Service Account to a Shared Drive grants inherited permissions to files within that folder.
What is the difference between 401 UNAUTHENTICATED and 403 PERMISSION_DENIED?
401 means missing, expired, or invalid credentials; 403 means your token/identity is valid, but lacks rights on the target resource or scope.
Which scope allows editing values via Sheets REST API v4?
Use https://www.googleapis.com/auth/spreadsheets or the narrower https://www.googleapis.com/auth/drive.file for app-created files.