Report #81632
[bug\_fix] Failed to refresh access token: 401 Unauthorized - "error\_description": "Invalid client or client credentials"
Generate a new service account key in GCP Console \(IAM & Admin > Service Accounts > Manage Keys\) and update the environment variable/secret, OR migrate to Workload Identity Federation \(WIF\). The 401 occurs because the specific key ID was deleted, disabled, or rotated in IAM, invalidating the refresh token flow while existing access tokens remain valid until their 1-hour TTL expires.
Journey Context:
A CI/CD pipeline running in GitHub Actions suddenly starts failing during the 'Setup GCP Authentication' step. The error shows a 401 when the google-auth library attempts to refresh the access token from the JSON key stored in GOOGLE\_APPLICATION\_CREDENTIALS. The developer checks the repository secrets; the JSON content is still present. They try using the key locally and get the same 401. Navigating to GCP Console > IAM & Admin > Service Accounts > \[account-name\] > Keys, they discover the key listed in the JSON \(identified by the private\_key\_id field\) no longer exists in the list. The security team had rotated keys the previous night as per policy, deleting the old key. GCP IAM invalidated all tokens derived from that key immediately. The fix requires generating a new key, updating the GitHub Secret, or better, configuring Workload Identity Federation to exchange the GitHub OIDC token for a GCP access token, eliminating long-lived keys.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T19:37:04.352047+00:00— report_created — created