Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All guides
GCP with AI By James Joyner IV · · 8 min read Last reviewed Jul 2026

GCP Error: 'Request is missing required authentication credential' — Cause, Fix, and Troubleshooting Guide

Quick answer

Fix GCP 401 'Request is missing required authentication credential' (UNAUTHENTICATED): supply ADC, an OAuth token, or a valid API key to the request.

  • #gcp
  • #troubleshooting
  • #errors
  • #iam
Free toolkit

Stuck on this GCP with AI error? Get the free incident triage checklist

A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.

Overview

This is a 401 UNAUTHENTICATED, not a 403. Google could not identify who is calling at all — the request carried no usable credential (no OAuth token, no valid API key):

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential.
                Expected OAuth 2 access token, login cookie or other valid
                authentication credential. See
                https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

Contrast with a 403: a 403 means “I know who you are, but you’re not allowed.” A 401 means “I don’t know who you are.” The fix is always about providing a credential, never about IAM roles.

Symptoms

  • Client libraries or curl calls to *.googleapis.com return HTTP 401 with UNAUTHENTICATED.
  • Code runs locally (where you logged in) but 401s in a container/CI where no credential is mounted.
  • A raw curl to a Google API without an Authorization: Bearer header fails.
  • DefaultCredentialsError: Could not automatically determine credentials from the client libraries.

Common Root Causes

1. Application Default Credentials are not configured

The environment has no ADC — no GOOGLE_APPLICATION_CREDENTIALS, no gcloud auth application-default login, and no attached service account (off-GCP).

2. A raw HTTP request with no Authorization header

Hand-rolled REST/curl calls that never attach a bearer token.

3. Expired or empty token variable

An $(gcloud auth print-access-token) captured earlier has since expired, or the token env var is empty.

4. Wrong endpoint / API key expected

Some APIs (Maps, Translation basic) expect an API key; none was supplied.

How to Diagnose

All read-only.

# Is there any ADC in this environment?
gcloud auth application-default print-access-token 2>&1 | head -3

# Is GOOGLE_APPLICATION_CREDENTIALS set and does the file exist?
echo "${GOOGLE_APPLICATION_CREDENTIALS:-<unset>}"
[ -f "${GOOGLE_APPLICATION_CREDENTIALS:-/nonexistent}" ] && echo "key present" || echo "no key file"

# Reproduce with an explicit token to prove it's a credential problem
TOKEN=$(gcloud auth print-access-token)
curl -s -o /dev/null -w "%{http_code}\n" \
  -H "Authorization: Bearer ${TOKEN}" \
  "https://compute.googleapis.com/compute/v1/projects/acme-prod-platform/zones"

If the authenticated curl returns 200 while the app 401s, the app simply is not attaching a credential.

Fixes

Local dev — set up ADC:

gcloud auth application-default login

Containers / CI off-GCP — mount a credential:

export GOOGLE_APPLICATION_CREDENTIALS=/secrets/app-sa-key.json
# Better: Workload Identity Federation so no key file is needed

On GCP compute (GCE/GKE/Cloud Run) — use the attached service account. No key file: the client libraries read ADC from the metadata server automatically. Ensure a service account is attached to the resource.

Raw REST calls — attach the bearer token:

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://<api>.googleapis.com/..."

What to Watch Out For

  • 401 = no identity; 403 = identity present but unauthorized. Do not touch IAM bindings for a 401 — you will waste time.
  • The client libraries follow the ADC search order: GOOGLE_APPLICATION_CREDENTIALS → gcloud ADC → attached service account. If all three are empty, you get this 401.
  • Access tokens live ~1 hour; a token captured into a long-lived variable will start returning 401 once it expires — regenerate per request.
  • Prefer Workload Identity Federation / attached service accounts over key files to avoid missing-credential gaps entirely.
Free download · 368-page PDF

Fixed it? Get 500 GCP with AI & DevOps AI prompts — free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.

Did this fix your issue?

Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.