Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add token on VS Code from Huggingface CLI #2723

Open
Titiksha28 opened this issue Dec 29, 2024 · 1 comment
Open

Unable to add token on VS Code from Huggingface CLI #2723

Titiksha28 opened this issue Dec 29, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Titiksha28
Copy link

Describe the bug

" " " (env) PS C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator> huggingface-cli login

_|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
_|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
_|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
_|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
_|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|

To log in, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .

Token can be pasted using 'Right-Click'.
Enter your token (input will not be visible):
Add token as git credential? (Y/n) y
Traceback (most recent call last):
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\utils_http.py", line 406, in hf_raise_for_status
response.raise_for_status()
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\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

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

Traceback (most recent call last):
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\hf_api.py", line 1633, in whoami
hf_raise_for_status(r)
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\utils_http.py", line 460, 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:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Scripts\huggingface-cli.exe_main
.py", line 7, in
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\commands\huggingface_cli.py", line 57, in main
service.run()
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\commands\user.py", line 153, in run
login(
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\utils_deprecation.py", line 101, in inner_f
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\utils_deprecation.py", line 31, in inner_f
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub_login.py", line 130, in login
interpreter_login(new_session=new_session)
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\utils_deprecation.py", line 101, in inner_f
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\utils_deprecation.py", line 31, in inner_f
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\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:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub_login.py", line 404, in _login
token_info = whoami(token)
^^^^^^^^^^^^^
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\utils_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\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. " " "

This is the issue that I am not able to solve.

Reproduction

Traceback (most recent call last):
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\Lib\site-packages\huggingface_hub\utils_http.py", line 406, in hf_raise_for_status
response.raise_for_status()
File "C:\Users\DELL\OneDrive\Desktop\AI-Image-Generator\env\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

Logs

No response

System info

- huggingface_hub version: 0.27.0
- Platform: Windows-11-10.0.22631-SP0
- Python version: 3.12.5
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Running in Google Colab Enterprise ?: No
- Token path ?: C:\Users\DELL\.cache\huggingface\token
- Has saved token ?: False
- Configured git credential helpers: manager
- FastAI: N/A
- Tensorflow: N/A
- Torch: 2.5.1
- Jinja2: 3.1.5
- Graphviz: N/A
- keras: N/A
- Pydot: N/A
- Pillow: 11.0.0
- hf_transfer: N/A
- gradio: N/A
- tensorboard: N/A
- numpy: 2.2.1
- pydantic: N/A
- aiohttp: N/A
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: C:\Users\DELL\.cache\huggingface\hub
- HF_ASSETS_CACHE: C:\Users\DELL\.cache\huggingface\assets
- HF_TOKEN_PATH: C:\Users\DELL\.cache\huggingface\token
- HF_STORED_TOKENS_PATH: C:\Users\DELL\.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
@Titiksha28 Titiksha28 added the bug Something isn't working label Dec 29, 2024
@hanouticelina
Copy link
Contributor

Hi @Titiksha28, your issue is likely related to your authentication token. could you run huggingface-cli whoami to see if you're able to retrieve your Hugging Face account name ?
You can try regenerating a new token here : https://huggingface.co/settings/tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@hanouticelina @Titiksha28 and others