google-gemini / google-gemini/gemini-cli
Possible Bug? Gemini CLI throws 401 UNAUTHENTICATED error mid-session
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
While using the Gemini CLI, the tool was functioning normally until a prompt failed unexpectedly with a 401 UNAUTHENTICATED error citing ACCESS_TOKEN_TYPE_UNSUPPORTED. I tested it with other scripts, and the gemini api key seems to be fine.
Here is the raw output
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
✕ [API Error: {"error":{"message":"{\n \"error\": {\n \"code\": 401,\n \"message\":
\"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie
or other valid authentication credential. See
https://developers.google.com/identity/sign-in/web/devconsole-project.\",\n \"status\":
\"UNAUTHENTICATED\",\n \"details\": [\n {\n \"@type\":
\"type.googleapis.com/google.rpc.ErrorInfo\",\n \"reason\":
\"ACCESS_TOKEN_TYPE_UNSUPPORTED\",\n \"metadata\": {\n \"service\":
\"generativelanguage.googleapis.com\",\n \"method\":
\"google.ai.generativelanguage.v1beta.GenerativeService.StreamGenerateContent\"\n }\n
}\n ]\n }\n}\n","code":401,"status":""}}]
.
It could be a mistake from my side so let me know if i have done anything wrong
Contributor guide
Research direction
Start by reproducing the failure in Gemini CLI using the reported mid-session sequence and capture the raw 401 response. Check which authentication mode is active when StreamGenerateContent fails and compare it with the credentials that work in other scripts. Done means the same session can continue without an ACCESS_TOKEN_TYPE_UNSUPPORTED error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai, authentication, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100