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

Failed to login

Open super-chao1997 opened this issue 1 year ago • 19 comments

What happened?

Select Auth Method │ │ ● Login with Google │ │ ○ Gemini API Key │ │ ○ Vertex AI │ │ │ │ Failed to login. │ │ Message: request to https://oauth2.googleapis.com/token failed, reason: │ │ │ │ (Use Enter to select) │ │ │ │ Terms of Services and Privacy Notice for Gemini CLI │ │ │ │ https://github.com/google-gemini/gemini-cli/blob/main/docs/tos-privacy.md

What did you expect to happen?

Failed to login.

Client information

$ gemini /about
# paste output here

Login information

No response

Anything else we need to know?

No response

super-chao1997 avatar Jun 26 '25 06:06 super-chao1997

你除了需要设置项目id还需要设置项目的api-key set GEMINI_API_KEY=xxxx set GOOGLE_CLOUD_PROJECT=xxx

TmacChenQian avatar Jun 26 '25 08:06 TmacChenQian

你除了需要设置项目id还需要设置项目的api-key set GEMINI_API_KEY=xxxx set GOOGLE_CLOUD_PROJECT=xxx

只是google账号登录,无需输入APIkey和projectID吧?

ANTQQ2 avatar Jun 27 '25 07:06 ANTQQ2

解决方式是,打开你的代理,找到默认的监听端口,然后根据默认的端口,比如我这里是 本地socks监听端口 10808 http端口=+1; Pac端口=+4; *ray API端口= +5; mihomo API端口= +6; 那么就在cmd里面输入 set HTTP_PROXY=http://127.0.0.1:10809 set HTTPS_PROXY=http://127.0.0.1:10809 设置走https代理 接在再输入gimini 启动就行

gushi233 avatar Jun 29 '25 05:06 gushi233

还有就是记得在梯子的路由里面设置对443端口的代理

gushi233 avatar Jun 29 '25 09:06 gushi233

解决方式是,打开你的代理,找到默认的监听端口,然后根据默认的端口,比如我这里是 本地socks监听端口 10808 http端口=+1; Pac端口=+4; *ray API端口= +5; mihomo API端口= +6; 那么就在cmd里面输入 set HTTP_PROXY=http://127.0.0.1:10809 set HTTPS_PROXY=http://127.0.0.1:10809 设置走https代理 接在再输入gimini 启动就行

Mac环境下,Socks Port为7890。我直接键入export HTTP_PROXY="http://127.0.0.1:7890"和export HTTPS_PROXY="http://127.0.0.1:7890",解决了主楼同样的登录问题。以上仅供参考。

Tender-song avatar Jun 30 '25 05:06 Tender-song

有一件需要注意的事情是,这个console输入的这个是一次性的,下次打开需要再输入一遍

gushi233 avatar Jun 30 '25 06:06 gushi233

Image"

set HTTP_PROXY=http://127.0.0.1:10080 set HTTPS_PROXY=http://127.0.0.1:10080

longfei-zhang avatar Jul 01 '25 06:07 longfei-zhang

如果是使用clash的话可以直接这里

Image

lukewjh avatar Jul 02 '25 02:07 lukewjh

如果是使用clash的话可以直接这里

Image

感谢,Mihomo 直接开启虚拟网卡就可以了

Magicdover avatar Jul 02 '25 05:07 Magicdover

I had that problem using

npx https://github.com/google-gemini/gemini-cli it worked when i used:

npm install -g @google/gemini-cli
gemini

its weird, that it worked the npm way. i'm using nixos and shouldn't have any network issues here in europe. maybe its a different issue, but im not really sure how to debug it

Clausinho avatar Jul 02 '25 14:07 Clausinho

解决方式是,打开你的代理,找到默认的监听端口,然后根据默认的端口,比如我这里是 本地socks监听端口 10808 http端口=+1; Pac端口=+4; *ray API端口= +5; mihomo API端口= +6; 那么就在cmd里面输入 set HTTP_PROXY=http://127.0.0.1:10809 set HTTPS_PROXY=http://127.0.0.1:10809 设置走https代理 接在再输入gimini 启动就行

Mac环境下,Socks Port为7890。我直接键入export HTTP_PROXY="http://127.0.0.1:7890"和export HTTPS_PROXY="http://127.0.0.1:7890",解决了主楼同样的登录问题。以上仅供参考。

解决方式是,打开你的代理,找到默认的监听端口,然后根据默认的端口,比如我这里是 本地socks监听端口 10808 http端口=+1; Pac端口=+4; *ray API端口= +5; mihomo API端口= +6; 那么就在cmd里面输入 set HTTP_PROXY=http://127.0.0.1:10809 set HTTPS_PROXY=http://127.0.0.1:10809 设置走https代理 接在再输入gimini 启动就行

Mac环境下,Socks Port为7890。我直接键入export HTTP_PROXY="http://127.0.0.1:7890"和export HTTPS_PROXY="http://127.0.0.1:7890",解决了主楼同样的登录问题。以上仅供参考。

解决了。另外附一点自己遇到的Case,使用本地proxy一定要设置 http://127.0.0.1:7890 而非 http://localhost:7890。后者还是会导致请求失败:

API Error: exception TypeError: fetch failed sending request

isr4z6er avatar Jul 03 '25 08:07 isr4z6er

解决方式是,打开你的代理,找到默认的监听端口,然后根据默认的端口,比如我这里是 本地socks监听端口 10808 http端口=+1; Pac端口=+4; *ray API端口= +5; mihomo API端口= +6; 那么就在cmd里面输入 set HTTP_PROXY=http://127.0.0.1:10809 set HTTPS_PROXY=http://127.0.0.1:10809 设置走https代理 接在再输入gimini 启动就行

powershell的设置:$env:HTTP_PROXY = "http://127.0.0.1:10809" $env:HTTPS_PROXY = "http://127.0.0.1:10809"

super-chao1997 avatar Jul 03 '25 09:07 super-chao1997

I guess i might be in the wrong issue, but atleast what helped me was NODE_TLS_REJECT_UNAUTHORIZED=0 gemini ignoring the ssl cert i use to adblock using adguard.

Clausinho avatar Jul 03 '25 18:07 Clausinho

Thank you @Clausinho, this helped me.

attilapalfi92 avatar Jul 04 '25 06:07 attilapalfi92

如果是使用clash的话可以直接这里 Image

谢谢,Mihomo直接开启虚拟网卡就可以了

感谢! clash直接开启虚拟网卡也解决了。

L-delta-lab avatar Jul 05 '25 01:07 L-delta-lab

开启虚拟网卡模型完美解决

wsl1717 avatar Jul 10 '25 02:07 wsl1717

有一件需要注意的事情是,这个console输入的这个是一次性的,下次打开需要再输入一遍

A convenient way is to set http_proxy and https_proxy in the system environment variables on windows to http://127.0.0.1:7890 to avoid repeated input before each login.

Yimsun97 avatar Jul 17 '25 17:07 Yimsun97

Hi,

Thank you all for your feedback, we have made significant improvements in this space and you should no longer run into this issue.

Please dont hesitate to reach out if you still see this issue and I'd be happy to re-open this issue for you.

srithreepo avatar Aug 30 '25 18:08 srithreepo

My country Bangladesh phone US this problem 2FA setting up

On Sun, 31 Aug 2025, 12:40 am Srinath Padmanabhan, @.***> wrote:

srithreepo left a comment (google-gemini/gemini-cli#1802) https://github.com/google-gemini/gemini-cli/issues/1802#issuecomment-3239450285

Hi,

Thank you all for your feedback, we have made significant improvements in this space and you should no longer run into this issue.

Please dont hesitate to reach out if you still see this issue and I'd be happy to re-open this issue for you.

— Reply to this email directly, view it on GitHub https://github.com/google-gemini/gemini-cli/issues/1802#issuecomment-3239450285, or unsubscribe https://github.com/notifications/unsubscribe-auth/BUYLOELT7Y4YVA6JDZGWAKD3QHV2LAVCNFSM6AAAAACAFIY7WSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMZZGQ2TAMRYGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- The good thing is to do with the process of getting the update.

-- Think it will get better and process issue.

danowar2 avatar Aug 30 '25 18:08 danowar2