Report #15325
[bug\_fix] Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential
Verify that the service account key JSON file has not been deleted, disabled, or invalidated. In the GCP Console, navigate to IAM > Service Accounts > \[account\] > Keys. If the key listed in the JSON \(\`private\_key\_id\`\) is not present or shows as inactive, the key is invalid. Generate a new key for an active service account, or preferably migrate to Workload Identity Federation \(e.g., for GitHub Actions or GitLab CI\) to eliminate long-lived keys. The root cause is that the private key ID referenced in the JSON file no longer exists in the service account \(deleted during a key rotation\), the service account itself was deleted, or the key was disabled by a security admin.
Journey Context:
A developer has a CI/CD pipeline in GitHub Actions that deploys infrastructure using Terraform. The workflow uses a GCP service account key stored as a GitHub Secret named \`GCP\_SA\_KEY\`. The pipeline has worked for months but suddenly starts failing during the \`terraform plan\` step with "Request had invalid authentication credentials". The developer checks the secret in GitHub - it appears to be a valid JSON with \`client\_email\`, \`private\_key\`, and \`token\_uri\`. They try to run \`gcloud auth activate-service-account --key-file=key.json\` locally with the same key file and get "Invalid grant: Not a valid email or user ID". They check the IAM console for the service account \`[email protected]\` - the account exists and shows as active. However, when they navigate to the "Keys" section of the service account, they see that the key ID matching the \`private\_key\_id\` in the JSON file is no longer listed. They recall that the security team recently implemented a policy to automatically delete service account keys older than 90 days. The key was deleted, rendering the JSON file invalid. The developer generates a new key temporarily to restore the pipeline, then immediately migrates the workflow to use Workload Identity Federation with GitHub Actions, eliminating the need for long-lived keys and preventing the error from recurring.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:47:56.456787+00:00— report_created — created