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

CLI requires re-login on every new terminal session on Windows

Open Wenjunyun123 opened this issue 1 year ago • 2 comments

What happened?

I am experiencing an issue where the Google Gemini CLI prompts me to log in every time I open a new terminal session and attempt to use the gemini command. This behavior is inconvenient as it requires repeated authentication.

I have investigated the local configuration files for the Gemini CLI, located in C:\Users<MyUser>.gemini, to understand the authentication mechanism and identify potential causes for this issue.

  1. oauth_creds.json Analysis: The oauth_creds.json file contains the OAuth 2.0 credentials, including an access_token and a refresh_token. The access_token has a very short lifespan (approximately 1 hour). While a refresh_token is present, indicating the capability for automatic token renewal, the CLI does not appear to be utilizing it to obtain a new access_token when the current one expires. This leads to the repeated login prompts.

    Content of oauth_creds.json (Redacted - Please replace with your own redacted content):

1 { 2 "access_token": "ya29.a0AS3H6N...<REDACTED_ACCESS_TOKEN>...0211", 3 "refresh_token": "1//06wm35_b2X3u...<REDACTED_REFRESH_TOKEN>...D_s", 4 "scope": "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid https://www.googleapis.com/auth/cloud-platform", 5 "token_type": "Bearer", 6 "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjljNjI1MTU4Nzk1MDg0NGE2NTZiZTM1NjNkOGM1YmQ2Zjg5NGM0MDciLCJ0eXAiOiJK V1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI2ODEyNTU4MDkzOTUtb284ZnQyb3ByZH JucDllM2FxZjZhdjNobWRpYjEzNWouYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiI2ODEyNTU4MDkzOTUtb28 4ZnQyb3ByZHJucDllM2FxZjZhdjNobWRpYjEzNWouYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDYzMDI0 NDAzNDU5MTA4Njk4NjYiLCJlbWFpbCI6InlvdWFpMjYzMjk0QGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhd F9oYXNoIjoicTBUV1FzQUctSXpRcnpzZkxFS0E0ZyIsIm5hbWUiOiJ5b3UgQUkiLCJwaWN0dXJlIjoiaHR0cHM6Ly9saDMuZ2 9vZ2xldXNlcmNvbnRlbnQuY29tL2EvQUNnOG9jS04xQVl2ZEZlYWhOMGhheTFRNWVpMjRBcVVmS1RmR2ttRlBw......hL1C8HJQ", 7 "expiry_date": 1757440921080 8 }

  1. google_accounts.json Analysis: This file simply indicates the active Google account used by the CLI. It does not contain any settings related to token refresh.

    Content of google_accounts.json:

1 { 2 "active": "[email protected]", 3 "old": [] 4 }

  1. settings.json Analysis: This file contains general settings for the CLI, but none of the parameters (hasSeenIdeIntegrationNudge, ideMode, selectedAuthType) appear to control or influence the token refresh mechanism.

    Content of settings.json: 1 { 2 "hasSeenIdeIntegrationNudge": true, 3 "ideMode": true, 4 "selectedAuthType": "oauth-personal" 5 }

Conclusion:

Based on the analysis of the configuration files, the issue does not appear to be a misconfiguration on my part. The problem is almost certainly a bug within the Google Gemini CLI application itself, specifically concerning its inability to automatically refresh the access token using the provided refresh token.

What did you expect to happen?

I expect the Gemini CLI to maintain my login session across different terminal sessions, automatically refreshing the access token using the refresh token, so that I do not have to re-authenticate every time I use the gemini command.

Client information

Client Information

Run gemini to enter the interactive CLI, then run the /about command.

> /about
# paste output here

Login information

No response

Anything else we need to know?

No response

Wenjunyun123 avatar Sep 09 '25 17:09 Wenjunyun123

This is a bug in the authentication flow where the CLI does not use the refresh token, forcing re-login on each new terminal session. The priority is set to P2 and status is 'need-information' because the user has not provided the output of the /about command which contains the CLI version.

gemini-cli[bot] avatar Sep 09 '25 17:09 gemini-cli[bot]

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 14 '25 00:12 gemini-cli[bot]