# Now, did I issue the token incorrectly?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnow-did-i-issue-the-token-incorrectly%2F151773%3E%5C
**Category:** Beginners\
**Created:** [April 22, 2025, 9:15am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnow-did-i-issue-the-token-incorrectly%2F151773 "2025-04-22T09:15:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbuwel](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kbuwel/32/46076_2.png) [@kbuwel](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fkbuwel)%5C
**Post date:** [April 22, 2025, 9:15am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnow-did-i-issue-the-token-incorrectly%2F151773%2F1 "2025-04-22T09:15:34Z")

</div>

I’ve been struggling with tokens all day today. I typed the huggingface-cli login command in anaconda and entered the token I received. And I keep getting the following error message:  
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.  
I have issued and refreshed tokens more than 5 times today.  
At first, I was able to log in.  
However, the 401 permission error did not go away, and I entered the newly issued token, but I am not able to log in at all.  
How do I solve this problem?  
I was issued a token that can read and write. After issuing, I pressed the button to save it to the clipboard.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [April 22, 2025, 9:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnow-did-i-issue-the-token-incorrectly%2F151773%2F2 "2025-04-22T09:35:12Z")

</div>

Maybe it’s because it’s Anaconda that the token isn’t being passed properly…?

If the token isn’t being passed even after calling login() within the program, that’s quite a headache. It could also be a network connection issue. Anyway, the reasons and solutions seem to vary widely depending on the person…

It might also happen when using a gated model, but I think that’s probably not the case this time.

> [@Error 401 Client Error: Unauthorized for url](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ferror-401-client-error-unauthorized-for-url%2F19714)%3A
>
> When using model card of my private speech recognition model with LM, I got this error: 401 Client Error: Unauthorized for url: [https://huggingface.co/api/models/taliai/tali-asr-with-lm/revision/main](https://huggingface.co/api/models/taliai/tali-asr-with-lm/revision/main) while the same model without lm works fine. Is there anything wrong on my model or model card or … Any help is appreciated.

> <https://github.com/huggingface/huggingface_hub/issues/2586>
>
> \### Describe the bug
> 
> I got access to Llama-3.2 but when I tried to access the… model, I got the 401 Error.
> 
> \`\`\`
> OSError: You are trying to access a gated repo.
> Make sure to have access to it at https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct.
> 401 Client Error. (Request ID: Root=1-66fc667a-79545df845c9253539ea509f;f6f84d32-d328-45e5-b78d-96461057d7d0)
> 
> Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/resolve/main/config.json.
> Access to model meta-llama/Llama-3.2-1B-Instruct is restricted. You must have access to it and be authenticated to access it. Please log in.
> \`\`\`
> 
> Now this means either I don't have access to 3.2B or I am not logged in. I got approved access, so it's not the first one (more about this in Reproduction).
> 
> I added my HF token key using \`huggingface-cli login\`, but I am still facing the same issue after that.
> 
> I tried to debug and found that the command \`huggingface-cli whoami\` gives me this error - 
> \`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. {"error":"Invalid username or password."}\`
> 
> So, basically even if I login (either via CLI or in code), I am getting this error
> 
> \`\`\`
> from huggingface\_hub import login
> login(token = "xxx")
> \`\`\`
> 
> \*\*Note:\*\* The only change I made (from yesterday when Llama-2 is working to today) is to change some environment variables i.e
> \`\`\`
> export HF\_HOME=xxx
> export HF\_ASSETS\_CACHE=xxx
> export XDG\_CACHE\_HOME=xxx
> export HF\_TOKEN=xxx
> export HF\_HUB\_CACHE=xxx
> \`\`\`
> 
> \### Reproduction
> 
> I also experimented with \`Llama-2-7B\` (which I used till yesterday and it was fine) but was getting the same \`GatedError\`.
> 
> \`\`\`
> from transformers import AutoTokenizer
> import transformers
> import torch
> 
> from huggingface\_hub import login
> login(token = "xxx")
> 
> model = "meta-llama/Llama-2-7b-chat-hf"
> 
> tokenizer = AutoTokenizer.from\_pretrained(model)
> pipeline = transformers.pipeline(
> "text-generation",
> model=model,
> torch\_dtype=torch.float16,
> device\_map="auto",
> )
> 
> sequences = pipeline(
> 'I liked "Breaking Bad" and "Band of Brothers". Do you have any recommendations of other shows I might like?\\n',
> do\_sample=True,
> top\_k=10,
> num\_return\_sequences=1,
> eos\_token\_id=tokenizer.eos\_token\_id,
> max\_length=200,
> )
> for seq in sequences:
> print(f"Result: {seq\['generated\_text'\]}")
> \`\`\`
> \### Logs
> 
> \`\`\`
> 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.
> Token is valid (permission: fineGrained).
> Your token has been saved to /qumulo/satya/huggingface/token
> Login successful
> Traceback (most recent call last):
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/utils/\_http.py", line 406, in hf\_raise\_for\_status
> response.raise\_for\_status()
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/requests/models.py", line 1021, in raise\_for\_status
> raise HTTPError(http\_error\_msg, response=self)
> requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/meta-llama/Llama-2-7b-chat-hf/resolve/main/config.json
> 
> The above exception was the direct cause of the following exception:
> 
> Traceback (most recent call last):
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/transformers/utils/hub.py", line 403, in cached\_file
> resolved\_file = hf\_hub\_download(
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/utils/\_deprecation.py", line 101, in inner\_f
> return f(\*args, \*\*kwargs)
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/utils/\_validators.py", line 114, in \_inner\_fn
> return fn(\*args, \*\*kwargs)
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/file\_download.py", line 1232, in hf\_hub\_download
> return \_hf\_hub\_download\_to\_cache\_dir(
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/file\_download.py", line 1339, in \_hf\_hub\_download\_to\_cache\_dir
> \_raise\_on\_head\_call\_error(head\_call\_error, force\_download, local\_files\_only)
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/file\_download.py", line 1854, in \_raise\_on\_head\_call\_error
> raise head\_call\_error
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/file\_download.py", line 1746, in \_get\_metadata\_or\_catch\_error
> metadata = get\_hf\_file\_metadata(
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/utils/\_validators.py", line 114, in \_inner\_fn
> return fn(\*args, \*\*kwargs)
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/file\_download.py", line 1666, in get\_hf\_file\_metadata
> r = \_request\_wrapper(
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/file\_download.py", line 364, in \_request\_wrapper
> response = \_request\_wrapper(
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/file\_download.py", line 388, in \_request\_wrapper
> hf\_raise\_for\_status(response)
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/huggingface\_hub/utils/\_http.py", line 423, in hf\_raise\_for\_status
> raise \_format(GatedRepoError, message, response) from e
> huggingface\_hub.errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-66fc6aa2-51edf73166f9906f2c6e4de2;44b58636-df14-4a1a-bb9c-4d83423f68ed)
> 
> Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-2-7b-chat-hf/resolve/main/config.json.
> Access to model meta-llama/Llama-2-7b-chat-hf is restricted. You must have access to it and be authenticated to access it. Please log in.
> 
> The above exception was the direct cause of the following exception:
> 
> Traceback (most recent call last):
> File "/qumulo/satya/Compress\_Align/scratch\_code/pytorch\_test.py", line 15, in \<module\>
> tokenizer = AutoTokenizer.from\_pretrained(model)
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/transformers/models/auto/tokenization\_auto.py", line 864, in from\_pretrained
> config = AutoConfig.from\_pretrained(
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/transformers/models/auto/configuration\_auto.py", line 1006, in from\_pretrained
> config\_dict, unused\_kwargs = PretrainedConfig.get\_config\_dict(pretrained\_model\_name\_or\_path, \*\*kwargs)
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/transformers/configuration\_utils.py", line 567, in get\_config\_dict
> config\_dict, kwargs = cls.\_get\_config\_dict(pretrained\_model\_name\_or\_path, \*\*kwargs)
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/transformers/configuration\_utils.py", line 626, in \_get\_config\_dict
> resolved\_config\_file = cached\_file(
> File "/qumulo/satya/anaconda3/envs/prune\_llm/lib/python3.9/site-packages/transformers/utils/hub.py", line 421, in cached\_file
> raise EnvironmentError(
> OSError: You are trying to access a gated repo.
> Make sure to have access to it at https://huggingface.co/meta-llama/Llama-2-7b-chat-hf.
> 401 Client Error. (Request ID: Root=1-66fc6aa2-51edf73166f9906f2c6e4de2;44b58636-df14-4a1a-bb9c-4d83423f68ed)
> 
> Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-2-7b-chat-hf/resolve/main/config.json.
> Access to model meta-llama/Llama-2-7b-chat-hf is restricted. You must have access to it and be authenticated to access it. Please log in.
> \`\`\`
> 
> \### System info
> 
> \`\`\`shell
> \- huggingface\_hub version: 0.25.1
> \- Platform: Linux-5.15.0-1065-nvidia-x86\_64-with-glibc2.35
> \- Python version: 3.9.19
> \- Running in iPython ?: No
> \- Running in notebook ?: No
> \- Running in Google Colab ?: No
> \- Running in Google Colab Enterprise ?: No
> \- Token path ?: /qumulo/satya/huggingface/token
> \- Has saved token ?: True
> \- Configured git credential helpers: 
> \- FastAI: N/A
> \- Tensorflow: N/A
> \- Torch: 2.4.1
> \- Jinja2: 3.1.4
> \- Graphviz: N/A
> \- keras: N/A
> \- Pydot: N/A
> \- Pillow: N/A
> \- hf\_transfer: N/A
> \- gradio: N/A
> \- tensorboard: N/A
> \- numpy: 1.26.4
> \- pydantic: 2.9.2
> \- aiohttp: 3.10.8
> \- ENDPOINT: https://huggingface.co
> \- HF\_HUB\_CACHE: /qumulo/satya/huggingface
> \- HF\_ASSETS\_CACHE: /qumulo/satya/huggingface
> \- HF\_TOKEN\_PATH: /qumulo/satya/huggingface/token
> \- 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
> \`\`\`
