gemini-cli - 💡(How to fix) Fix Bug: OAuth login fails with 403 "Cloud Code Private API has not been used in project 276287556352" (Ignores GOOGLE_CLOUD_PROJECT) [1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#26105Fetched 2026-04-29 06:35:58
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
labeled ×1subscribed ×1

Error Message

When attempting to authenticate the CLI using gemini auth login (OAuth) with a Google account that has a Gemini Advanced/Pro subscription, the login flow completes in the browser, but the CLI immediately crashes with a 403 PERMISSION_DENIED error. The error states that the Cloud Code Private API is not enabled in project 276287556352. This is an internal Google "Ghost Project" (likely the project that owns the CLI's hardcoded OAuth 2.0 Client ID) rather than the user's actual Google Cloud Project. 6. The terminal returns the 403 Ghost Project error. The CLI throws the following error:

Root Cause

When attempting to authenticate the CLI using gemini auth login (OAuth) with a Google account that has a Gemini Advanced/Pro subscription, the login flow completes in the browser, but the CLI immediately crashes with a 403 PERMISSION_DENIED error. The error states that the Cloud Code Private API is not enabled in project 276287556352. This is an internal Google "Ghost Project" (likely the project that owns the CLI's hardcoded OAuth 2.0 Client ID) rather than the user's actual Google Cloud Project. Furthermore, explicitly setting the GOOGLE_CLOUD_PROJECT environment variable does not resolve the issue, as the CLI appears to be failing to pass this variable as the x-goog-user-project quota header when communicating with the cloudcode-pa.googleapis.com endpoint. To Reproduce Steps to reproduce the behavior:

  1. Ensure you have a Gemini Pro/Advanced subscription on your Google account.
  2. Completely clear old credentials (rm -rf ~/.gemini, clear macOS keychain).
  3. Export a valid GCP project: export GOOGLE_CLOUD_PROJECT="my-valid-gcp-project"
  4. Run gemini auth login
  5. Complete the browser sign-in.
  6. The terminal returns the 403 Ghost Project error. Expected behavior The CLI should successfully authenticate. Because the account has a Gemini Pro consumer subscription, it should either bypass the GCP project quota requirement entirely, OR it should successfully read the GOOGLE_CLOUD_PROJECT environment variable and pass it in the x-goog-user-project header to the API gateway. Actual behavior The CLI throws the following error: Failed to sign in. Message: Cloud Code Private API has not been used in project 276287556352 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudcode-pa.googleapis.com/overview?project=276287556352 then retry. Environment details:
  • OS: macOS (darwin)
  • CLI Version: 0.38.2 and 0.39.1 (npm & Homebrew)
  • Node Version: Insert your node version, e.g., v20.x.x
  • Auth Method: oauth-personal Additional Context & Root Cause Analysis We did a deep dive into the bundled source code and found the following:
  1. The API Key method (export GEMINI_API_KEY="...") works perfectly because it routes to generativelanguage.googleapis.com.
  2. The OAuth method routes to cloudcode-pa.googleapis.com.
  3. In the bundled source code (oauth2.ts / chunk-X5TOY4FB.js), the OAuth2Client is initialized, but when the backend entitlement check fails, the API Gateway demands a quota project.
  4. The code fetching the credentials does not seem to accurately inject process.env.GOOGLE_CLOUD_PROJECT into the quotaProjectId / x-goog-user-project header for the loadCodeAssist request. Consequently, the API Gateway defaults to the project ID of the OAuth Client (276287556352), resulting in an immediate 403.
RAW_BUFFERClick to expand / collapse

When attempting to authenticate the CLI using gemini auth login (OAuth) with a Google account that has a Gemini Advanced/Pro subscription, the login flow completes in the browser, but the CLI immediately crashes with a 403 PERMISSION_DENIED error. The error states that the Cloud Code Private API is not enabled in project 276287556352. This is an internal Google "Ghost Project" (likely the project that owns the CLI's hardcoded OAuth 2.0 Client ID) rather than the user's actual Google Cloud Project. Furthermore, explicitly setting the GOOGLE_CLOUD_PROJECT environment variable does not resolve the issue, as the CLI appears to be failing to pass this variable as the x-goog-user-project quota header when communicating with the cloudcode-pa.googleapis.com endpoint. To Reproduce Steps to reproduce the behavior:

  1. Ensure you have a Gemini Pro/Advanced subscription on your Google account.
  2. Completely clear old credentials (rm -rf ~/.gemini, clear macOS keychain).
  3. Export a valid GCP project: export GOOGLE_CLOUD_PROJECT="my-valid-gcp-project"
  4. Run gemini auth login
  5. Complete the browser sign-in.
  6. The terminal returns the 403 Ghost Project error. Expected behavior The CLI should successfully authenticate. Because the account has a Gemini Pro consumer subscription, it should either bypass the GCP project quota requirement entirely, OR it should successfully read the GOOGLE_CLOUD_PROJECT environment variable and pass it in the x-goog-user-project header to the API gateway. Actual behavior The CLI throws the following error: Failed to sign in. Message: Cloud Code Private API has not been used in project 276287556352 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudcode-pa.googleapis.com/overview?project=276287556352 then retry. Environment details:
  • OS: macOS (darwin)
  • CLI Version: 0.38.2 and 0.39.1 (npm & Homebrew)
  • Node Version: Insert your node version, e.g., v20.x.x
  • Auth Method: oauth-personal Additional Context & Root Cause Analysis We did a deep dive into the bundled source code and found the following:
  1. The API Key method (export GEMINI_API_KEY="...") works perfectly because it routes to generativelanguage.googleapis.com.
  2. The OAuth method routes to cloudcode-pa.googleapis.com.
  3. In the bundled source code (oauth2.ts / chunk-X5TOY4FB.js), the OAuth2Client is initialized, but when the backend entitlement check fails, the API Gateway demands a quota project.
  4. The code fetching the credentials does not seem to accurately inject process.env.GOOGLE_CLOUD_PROJECT into the quotaProjectId / x-goog-user-project header for the loadCodeAssist request. Consequently, the API Gateway defaults to the project ID of the OAuth Client (276287556352), resulting in an immediate 403.
<img width="1920" height="1080" alt="Image" src="https://github.com/user-attachments/assets/bb853f24-1232-4e35-a86d-1f0d0bd0cabb" />

extent analysis

TL;DR

The Gemini CLI crashes with a 403 PERMISSION_DENIED error due to the Cloud Code Private API not being enabled in the internal Google "Ghost Project" and the CLI failing to pass the GOOGLE_CLOUD_PROJECT environment variable as the x-goog-user-project quota header.

Guidance

  • Verify that the GOOGLE_CLOUD_PROJECT environment variable is set correctly before running the gemini auth login command.
  • Check the OAuth2Client initialization in the oauth2.ts file to ensure it is correctly handling the quota project ID.
  • Investigate why the process.env.GOOGLE_CLOUD_PROJECT is not being injected into the quotaProjectId/x-goog-user-project header for the loadCodeAssist request.
  • Consider using the API Key method (export GEMINI_API_KEY="...") as a temporary workaround, as it routes to a different endpoint (generativelanguage.googleapis.com) that does not require the Cloud Code Private API.

Notes

The issue seems to be related to the OAuth method routing to cloudcode-pa.googleapis.com and the failure to inject the GOOGLE_CLOUD_PROJECT environment variable into the quota project ID header. The API Key method works because it uses a different endpoint.

Recommendation

Apply workaround: Use the API Key method (export GEMINI_API_KEY="...") until the OAuth method is fixed, as it allows authentication without requiring the Cloud Code Private API.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING