gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

[v0.1.16] OAuth token not loaded unless running from ~/.gemini; symlink/copy fallback broken across CWDs

Open michelsdev opened this issue 1 year ago • 6 comments

What happened?

Gemini CLI v0.1.16 improperly ignores the OAuth credentials stored in ~/.gemini/oauth_creds.json when launched from any working directory other than ~/.gemini. Creating a local .gemini/ folder by copying credentials or adding a symlink to ~/.gemini does not help—the CLI still opens a browser login every time.

What did you expect to happen?

I expect the CLI to check the home directory fallback but currently it does not.

Client information

  • CLI Version: 0.1.16
  • Git Commit: 820169ba (local modifications)
  • Operating System: linux v22.15.1
  • Sandbox Environment: no sandbox
  • Model Version: gemini-2.5-flash
  • Memory Usage: 175.5 MB

Login information

Google Account

Anything else we need to know?

What happened? After successfully completing gemini login in my home directory, ~/.gemini/oauth_creds.json contains valid refresh and access tokens.

When launching gemini within ~/.gemini/, you are logged in immediately without further browser interaction.

When launching from any other directory (e.g. ~/projects/foo), the CLI attempts OAuth login again—even if:

~/projects/foo/.gemini/oauth_creds.json and settings.json exist (copied manually),

or ~/projects/foo/.gemini → ~/.gemini symlink is present.

The CLI ignores CLI-auth JSON files outside the home context, so credentials are not reused.

michelsdev avatar Aug 03 '25 18:08 michelsdev

Are you still seeing this with the latest version? I cannot reproduce.

Does it require a login every time you run? If so, this means it's not able to store the credentials where it's expecting to. It could be a permission issue. Also, try pressing ctrl-o to open the debug console to see if it contains any useful error messages.

scidomino avatar Aug 29 '25 16:08 scidomino

Follow up question: When you say "It doesn't work except when running from ~/.gemini" do you mean "running from ~"? I wrote this code and I don't know what the behavior is when running inside the .gemini dir.

scidomino avatar Aug 29 '25 16:08 scidomino

Additional logs: response: { config: { url: 'https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse', method: 'POST', params: [Object], headers: [Object], responseType: 'stream', body: '< - See errorRedactor option in gaxios for configuration>.', signal: [AbortSignal], paramsSerializer: [Function: paramsSerializer], validateStatus: [Function: validateStatus], errorRedactor: [Function: defaultErrorRedactor] }, data: '[{\n' + ' "error": {\n' + ' "code": 429,\n' + "message": "Quota exceeded for quota metric 'Gemini 2.5 Pro Requests' and limit 'Gemini 2.5 Pro Requests per day per user per tier' of service 'cloudcode-pa.googleapis.com' for consumer 'project_number:681255809395'.",\n + ' "errors": [\n' + ' {\n' + "message": "Quota exceeded for quota metric 'Gemini 2.5 Pro Requests' and limit 'Gemini 2.5 Pro Requests per day per user per tier' of service 'cloudcode-pa.googleapis.com' for consumer 'project_number:681255809395'.",\n + ' "domain": "global",\n' + ' "reason": "rateLimitExceeded"\n' + ' }\n' + ' ],\n' + ' "status": "RESOURCE_EXHAUSTED"\n' + ' }\n' + '}\n' + ']', headers: { 'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000', 'content-length': '630', 'content-type': 'application/json; charset=UTF-8', date: 'Sat, 06 Sep 2025 05:54:30 GMT', server: 'ESF', 'server-timing': 'gfet4t7; dur=181', vary: 'Origin, X-Origin, Referer', 'x-content-type-options': 'nosniff', 'x-frame-options': 'SAMEORIGIN', 'x-xss-protection': '0' }, status: 429, statusText: 'Too Many Requests', request: { responseURL: 'https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse' } }, error: undefined, status: 429, Symbol(gaxios-gaxios-error): '6.7.1' }

According to this logs it use project_number:681255809395, which is wrong project number. I think that might be the root cause.

grimmy0 avatar Sep 06 '25 05:09 grimmy0

project_number:681255809395 is the global project used for global quota enforcement so that's expected. I don't think that's related to the orginal issue described above.

scidomino avatar Sep 08 '25 18:09 scidomino

Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.

It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.

Thank you for your contribution!

gemini-cli[bot] avatar Dec 03 '25 22:12 gemini-cli[bot]

Found possible duplicate issues:

  • #4723
  • #2865
  • #10971
  • #11937
  • #10881
  • #8883
  • #8096

If you believe this is not a duplicate, please remove the status/possible-duplicate label.

gemini-cli[bot] avatar Dec 04 '25 19:12 gemini-cli[bot]