[BUG] Authentication with "GOOGLE_APPLICATION_CREDENTIALS" does not seem to work

Resolved 💬 6 comments Opened Nov 6, 2025 by markusl Closed Jan 12, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The documentation says: "When authenticating, Claude Code will automatically use the project ID from the ANTHROPIC_VERTEX_PROJECT_ID environment variable. To override this, set one of these environment variables: GCLOUD_PROJECT, GOOGLE_CLOUD_PROJECT, or GOOGLE_APPLICATION_CREDENTIALS."

However, when I'm authenticating for programmatic usage in a Jenkins job, the credentials are not used as expected:

    gcloud auth login --brief --cred-file="$WORKSPACE_TMP/creds.json" --impersonate-service-account=$WORK_SERVICE_ACCOUNT_ID
      
      export GOOGLE_APPLICATION_CREDENTIALS="$WORKSPACE_TMP/creds.json"

      gcloud --project <our-project-name> ai model-garden models list --model-filter=claude

      export GOOGLE_CLOUD_PROJECT=<our-project-name>
      export CLAUDE_CODE_USE_VERTEX=1
      export CLOUD_ML_REGION=us-east5
      ~/.local/bin/claude -p "Output a very short Haiku about Jenkins"

The output shows that the authentication is successful, but claude code is using wrong credentials:


+ gcloud --project <our-project-name> ai model-garden models list --model-filter=claude
Using endpoint [https://us-central1-aiplatform.googleapis.com/]
WARNING: This command is using service account impersonation. All API calls will be executed as [claude-jenkins-user@<our-project-name>.iam.gserviceaccount.com].
MODEL_ID                                CAN_DEPLOY  CAN_PREDICT
anthropic/claude-3-5-haiku@20241022     No          No
[snip]
anthropic/claude-sonnet-4@20250514      No          No
+ export GOOGLE_CLOUD_PROJECT=<our-project-name>
+ export CLAUDE_CODE_USE_VERTEX=1
+ export CLOUD_ML_REGION=us-east5
+ /home/builder/.local/bin/claude -p Output a very short Haiku about Jenkins
API Error: No projectId was given and it could not be resolved from credentials. The client should be instantiated with the `projectId` option or the `ANTHROPIC_VERTEX_PROJECT_ID` environment variable should be set.

What Should Happen?

It should be possible to use claude code with GOOGLE_APPLICATION_CREDENTIALS.

Error Messages/Logs

API Error: No projectId was given and it could not be resolved from credentials. The client should be instantiated with the `projectId` option or the `ANTHROPIC_VERTEX_PROJECT_ID` environment variable should be set.

Steps to Reproduce

Try to run Claude Code using "GOOGLE_APPLICATION_CREDENTIALS"
See https://docs.cloud.google.com/docs/authentication/application-default-credentials

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.34

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Non-interactive/CI environment

Additional Information

_No response_

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗