# Huggingface cli login error

**URL:** <https://discuss.huggingface.co/t/huggingface-cli-login-error/157361>\
**Category:** 🤗Hub\
**Created:** [May 30, 2025, 9:15am UTC](https://discuss.huggingface.co/t/huggingface-cli-login-error/157361 "2025-05-30T09:15:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sammac9801](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@sammac9801](https://discuss.huggingface.co/u/sammac9801)\
**Post date:** [May 30, 2025, 9:15am UTC](https://discuss.huggingface.co/t/huggingface-cli-login-error/157361/1 "2025-05-30T09:15:28Z")

</div>

logging in with access token stopped working (had no issues before), tried with 3 different tokens + on different huggingface\_hub envs, exact error trace is this

Traceback (most recent call last):  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\utils\_http.py”, line 409, in hf\_raise\_for\_status  
response.raise\_for\_status()  
File “C:\comfyenv\Lib\site-packages\requests\models.py”, line 1024, in raise\_for\_status  
raise HTTPError(http\_error\_msg, response=self)  
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: [https://huggingface.co/api/whoami-v2](https://huggingface.co/api/whoami-v2)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\hf\_api.py”, line 1746, in whoami  
hf\_raise\_for\_status(r)  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\utils\_http.py”, line 465, in hf\_raise\_for\_status  
raise \_format(BadRequestError, message, response) from e  
huggingface\_hub.errors.BadRequestError: Bad request:

The above exception was the direct cause of the following exception:

Traceback (most recent call last):  
File “”, line 198, in \_run\_module\_as\_main  
File “”, line 88, in _run\_code  
File "C:\comfyenv\scripts\huggingface-cli.exe\_main_.py", line 7, in   
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\commands\huggingface\_cli.py”, line 59, in main  
service.run()  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\commands\user.py”, line 111, in run  
login(  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\utils\_deprecation.py”, line 101, in inner\_f  
return f(\*args, \*\*kwargs)  
^^^^^^^^^^^^^^^^^^  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\utils\_deprecation.py”, line 31, in inner\_f  
return f(\*args, \*\*kwargs)  
^^^^^^^^^^^^^^^^^^  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\_login.py”, line 130, in login  
interpreter\_login(new\_session=new\_session)  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\utils\_deprecation.py”, line 101, in inner\_f  
return f(\*args, \*\*kwargs)  
^^^^^^^^^^^^^^^^^^  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\utils\_deprecation.py”, line 31, in inner\_f  
return f(\*args, \*\*kwargs)  
^^^^^^^^^^^^^^^^^^  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\_login.py”, line 290, in interpreter\_login  
\_login(token=token, add\_to\_git\_credential=add\_to\_git\_credential)  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\_login.py”, line 404, in \_login  
token\_info = whoami(token)  
^^^^^^^^^^^^^  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\utils\_validators.py”, line 114, in \_inner\_fn  
return fn(\*args, \*\*kwargs)  
^^^^^^^^^^^^^^^^^^^  
File “C:\comfyenv\Lib\site-packages\huggingface\_hub\hf\_api.py”, line 1759, in whoami  
raise HTTPError(error\_message, request=e.request, response=e.response) from e  
requests.exceptions.HTTPError: Invalid user token.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [May 30, 2025, 9:42am UTC](https://discuss.huggingface.co/t/huggingface-cli-login-error/157361/2 "2025-05-30T09:42:43Z")

</div>

It seems to be the `huggingface_hub` library in the ComfyUI environment, so it may not be a normal error, but here is how to deal with it if it is a normal error for now.

> [@Invalid token passed?](https://discuss.huggingface.co/t/invalid-token-passed/22711/4):
>
> The solution is quite simple, yet unexpected. you need to copy your token but instead of pasting it via CTRL+V you need to paste it into the console via a right click of your mouse.

> <https://github.com/huggingface/huggingface_hub/issues/2765#issuecomment-2604466707>
>
> \### Describe the bug
> 
> Firstly I apologize if it's really basic or trivial, but I… don't seem to understand how to login
> I'm trying to login with the huggingface-cli login and it keeps giving me the following
> 
> \`\`\`
> huggingface-cli login --token \<THE\_TOKEN\>
> The token has not been saved to the git credentials helper. Pass \`add\_to\_git\_credential=True\` in this function directly or \`--add-to-git-credential\` if using via \`huggingface-cli\` if you want to set the git credential as well.
> Traceback (most recent call last):
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/utils/\_http.py", line 406, in hf\_raise\_for\_status
> response.raise\_for\_status()
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/requests/models.py", line 1024, in raise\_for\_status
> raise HTTPError(http\_error\_msg, response=self)
> requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/api/whoami-v2
> 
> The above exception was the direct cause of the following exception:
> 
> Traceback (most recent call last):
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/hf\_api.py", line 1633, in whoami
> hf\_raise\_for\_status(r)
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/utils/\_http.py", line 477, in hf\_raise\_for\_status
> raise \_format(HfHubHTTPError, str(e), response) from e
> huggingface\_hub.errors.HfHubHTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/api/whoami-v2 (Request ID: Root=1-678e5498-0b3b190044e69e0613e6cff6;d4ef20db-e33b-42cc-ac5c-5643c9e9b530)
> 
> Invalid username or password.
> 
> The above exception was the direct cause of the following exception:
> 
> Traceback (most recent call last):
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/bin/huggingface-cli", line 8, in \<module\>
> sys.exit(main())
> ^^^^^^
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/commands/huggingface\_cli.py", line 57, in main
> service.run()
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/commands/user.py", line 153, in run
> login(
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/utils/\_deprecation.py", line 101, in inner\_f
> return f(\*args, \*\*kwargs)
> ^^^^^^^^^^^^^^^^^^
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/utils/\_deprecation.py", line 31, in inner\_f
> return f(\*args, \*\*kwargs)
> ^^^^^^^^^^^^^^^^^^
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/\_login.py", line 126, in login
> \_login(token, add\_to\_git\_credential=add\_to\_git\_credential)
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/\_login.py", line 404, in \_login
> token\_info = whoami(token)
> ^^^^^^^^^^^^^
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/utils/\_validators.py", line 114, in \_inner\_fn
> return fn(\*args, \*\*kwargs)
> ^^^^^^^^^^^^^^^^^^^
> File "/home/appsinacup/AlexStuff/ComfyUI/imgaienv/lib/python3.12/site-packages/huggingface\_hub/hf\_api.py", line 1635, in whoami
> raise HTTPError(
> requests.exceptions.HTTPError: Invalid user token. If you didn't pass a user token, make sure you are properly logged in by executing \`huggingface-cli login\`, and if you did pass a user token, double-check it's correct.
> \`\`\`
> 
> 
> also the token seems to work when testing it with 
> 
> \`\`\`
> curl -i https://huggingface.co/api/whoami-v2 \\
> -H "Authorization: Bearer \<THE TOKEN\>"
> HTTP/2 200
> content-type: application/json; charset=utf-8
> content-length: 382
> date: Mon, 20 Jan 2025 14:08:15 GMT
> x-powered-by: huggingface-moon
> cross-origin-opener-policy: same-origin
> referrer-policy: strict-origin-when-cross-origin
> x-request-id: Root=1-678e58cf-35223b3a7ca3d73215320b2d
> access-control-allow-origin: https://huggingface.co
> vary: Origin
> access-control-expose-headers: X-Repo-Commit,X-Request-Id,X-Error-Code,X-Error-Message,X-Total-Count,ETag,Link,Accept-Ranges,Content-Range,X-Xet-Access-Token,X-Xet-Token-Expiration,X-Xet-Refresh-Route,X-Xet-Cas-Url,X-Xet-Hash
> etag: W/"17e-uXTz1hbj/22y/TAql9VBBdqElGo"
> x-cache: Miss from cloudfront
> via: 1.1 e76c434a546615d1c8c0e096c588e7d4.cloudfront.net (CloudFront)
> x-amz-cf-pop: OTP50-P2
> x-amz-cf-id: 4T2TKFmHXP4ma4JeDw0sy4znD0ocV6p9kuv31krBlI0z4kSYbEGaaQ==
> 
> {"type":"user","id":"63dcf661f37111482522cda7","name":"propolys","fullname":"Alex","email":"alexander\_00012@yahoo.com","emailVerified":true,"canPay":false,"periodEnd":null,"isPro":false,"avatarUrl":"/avatars/eb4ec70ff9803cb66fab23117ff45b02.svg","orgs":\[\],"auth":{"type":"access\_token","accessToken":{"displayName":"Comfyread","role":"read","createdAt":"2025-01-20T13:02:07.690Z"}}}
> \`\`\`
> 
> Thank you for any help, and sorry again if it's a noob question
> 
> \### Reproduction
> 
> \_No response\_
> 
> \### Logs
> 
> \`\`\`shell
> 
> \`\`\`
> 
> \### System info
> 
> \`\`\`shell
> \- huggingface\_hub version: 0.27.1
> \- Platform: Linux-6.8.0-51-generic-aarch64-with-glibc2.39
> \- Python version: 3.12.3
> \- Running in iPython ?: No
> \- Running in notebook ?: No
> \- Running in Google Colab ?: No
> \- Running in Google Colab Enterprise ?: No
> \- Token path ?: /home/appsinacup/.cache/huggingface/token
> \- Has saved token ?: False
> \- Configured git credential helpers:
> \- FastAI: N/A
> \- Tensorflow: N/A
> \- Torch: 2.6.0.dev20241224+cu126
> \- Jinja2: 3.1.3
> \- Graphviz: N/A
> \- keras: N/A
> \- Pydot: 3.0.3
> \- Pillow: 11.1.0
> \- hf\_transfer: N/A
> \- gradio: N/A
> \- tensorboard: N/A
> \- numpy: 1.26.4
> \- pydantic: 2.10.3
> \- aiohttp: 3.11.10
> \- ENDPOINT: https://huggingface.co
> \- HF\_HUB\_CACHE: /home/appsinacup/.cache/huggingface/hub
> \- HF\_ASSETS\_CACHE: /home/appsinacup/.cache/huggingface/assets
> \- HF\_TOKEN\_PATH: /home/appsinacup/.cache/huggingface/token
> \- HF\_STORED\_TOKENS\_PATH: /home/appsinacup/.cache/huggingface/stored\_tokens
> \- HF\_HUB\_OFFLINE: False
> \- HF\_HUB\_DISABLE\_TELEMETRY: False
> \- HF\_HUB\_DISABLE\_PROGRESS\_BARS: None
> \- HF\_HUB\_DISABLE\_SYMLINKS\_WARNING: False
> \- HF\_HUB\_DISABLE\_EXPERIMENTAL\_WARNING: False
> \- HF\_HUB\_DISABLE\_IMPLICIT\_TOKEN: False
> \- HF\_HUB\_ENABLE\_HF\_TRANSFER: False
> \- HF\_HUB\_ETAG\_TIMEOUT: 10
> \- HF\_HUB\_DOWNLOAD\_TIMEOUT: 10
> \`\`\`

> **[Issues · comfyanonymous/ComfyUI](https://github.com/comfyanonymous/ComfyUI/issues)**
>
> The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. - Issues · comfyanonymous/ComfyUI
