# Invalid token or no access to Hugging Face

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finvalid-token-or-no-access-to-hugging-face%2F115807%3E%5C
**Category:** Beginners\
**Created:** [November 5, 2024, 10:30am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finvalid-token-or-no-access-to-hugging-face%2F115807 "2024-11-05T10:30:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cybertrone](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@cybertrone](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fcybertrone)%5C
**Post date:** [November 5, 2024, 10:30am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finvalid-token-or-no-access-to-hugging-face%2F115807%2F1 "2024-11-05T10:30:16Z")

</div>

Hello!  
The problem is: I’ve generated several tokens, but no one of them works=(  
Errors are: API: Authorization header is correct, but the token seems invalid  
Invalid token or no access to Hugging Face  
I tried write-token, read-token, token with all permissions.  
What am I doing wrong?

---

<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:** [November 5, 2024, 12:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finvalid-token-or-no-access-to-hugging-face%2F115807%2F2 "2024-11-05T12:16:28Z")

</div>

That’s a rare case. It’s not common for only the token to be wrong.  
Perhaps you’re trying to access the gated model but haven’t obtained permission for the individual gated model?  
Or maybe.

> **[google/flan-t5-xxl · Authorization header is correct, but the token seems...](https://huggingface.co/google/flan-t5-xxl/discussions/67)**
>
> raise ValueError(f"Error raised by inference API: {response\['error'\]}") ValueError: Error raised by inference API: Authorization header is correct, but the token seems invalid raise ValueError(f"E...

> <https://github.com/huggingface/huggingface_hub/issues/2507>
>
> \### Describe the bug
> 
> 
> So my issue is this error, I was working with same 'HF\_t…oken' having the write permission and I am working with Mistral Nemo 12B Instruct , the model was working well from last few days without any issue and today suddenly this error appears .
> This error appears to be persistant, i have refresh the token and also tried with other model too and also check the hugging face interface api server status as well, but the issue remains the same.
> 
> \### \*\*Issue\*\* 
> \*\*BadRequestError
> huggingface\_hub.utils.\_errors.BadRequestError: (Request ID: Mq1mDWKbogI0AleJS0HJM)\*\*
> 
> \*\*Bad request:
> Authorization header is correct, but the token seems invalid\*\*
> 
> This is my \`\`\`app.py\`\`\` file, and I have not modified or added any other files:
> 
> \`\`\`
> from huggingface\_hub import InferenceClient
> from dotenv import load\_dotenv
> 
> \# Load environment variables from .env file
> load\_dotenv()
> 
> \# Authenticate with Hugging Face
> HFT = os.getenv('HF\_TOKEN')
> client = InferenceClient(model="mistralai/Mistral-Nemo-Instruct-2407", token=HFT) 
> 
> \#results
> response = ""
> for message in client.chat\_completion(
> messages=\[system\_role, user\_prompt\],
> max\_tokens=3000,
> stream=True,
> temperature=0.35,
> ):
> response += message.choices\[0\].delta.content
> \`\`\`
> 
> 
> 
> \### Reproduction
> 
> \_No response\_
> 
> \### Logs
> 
> \`\`\`shell
> Traceback (most recent call last):
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\lib\\site-packages\\huggingface\_hub\\utils\\\_errors.py", line 304, in hf\_raise\_for\_status
> response.raise\_for\_status()
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\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: /static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fmistralai%2FMistral-Nemo-Instruct-2407%2Fv1%2Fchat%2Fcompletions
> 
> The above exception was the direct cause of the following exception:
> 
> Traceback (most recent call last):
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\lib\\site-packages\\flask\\app.py", line 1498, in \_\_call\_\_
> return self.wsgi\_app(environ, start\_response)
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\lib\\site-packages\\flask\\app.py", line 1476, in wsgi\_app
> response = self.handle\_exception(e)
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\lib\\site-packages\\flask\\app.py", line 1473, in wsgi\_app
> response = self.full\_dispatch\_request()
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\lib\\site-packages\\flask\\app.py", line 882, in full\_dispatch\_request
> rv = self.handle\_user\_exception(e)
> File "C:\\Users\\Admin\\Documents\\\_app\_30082024\\envo\\lib\\site-packages\\flask\\app.py", line 880, in full\_dispatch\_request
> rv = self.dispatch\_request()
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\lib\\site-packages\\flask\\app.py", line 865, in dispatch\_request
> return self.ensure\_sync(self.view\_functions\[rule.endpoint\])(\*\*view\_args) # type: ignore\[no-any-return\]
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\app5.py", line 78, in process\_file 
> per\_data = Model\_PersonalDetails\_Output(resume, client)
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\utility\\llm\_generate.py", line 127, in Model\_PersonalDetails\_Output
> for message in client.chat\_completion(
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\lib\\site-packages\\huggingface\_hub\\inference\\\_client.py", line 837, in chat\_completion
> data = self.post(
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\lib\\site-packages\\huggingface\_hub\\inference\\\_client.py", line 304, in post
> hf\_raise\_for\_status(response)
> File "C:\\Users\\Admin\\Documents\\app\_30082024\\envo\\lib\\site-packages\\huggingface\_hub\\utils\\\_errors.py", line 358, in hf\_raise\_for\_status
> raise BadRequestError(message, response=response) from e
> huggingface\_hub.utils.\_errors.BadRequestError: (Request ID: Mq1mDWKbogI0AleJS0HJM)
> 
> Bad request:
> Authorization header is correct, but the token seems invalid
> \`\`\`
> 
> 
> \### System info
> 
> \`\`\`shell
> \- huggingface\_hub version: 0.24.6
> \- Platform: Windows-10-10.0.19045-SP0
> \- Python version: 3.10.10
> \- Running in iPython ?: No
> \- Running in notebook ?: No
> \- Running in Google Colab ?: No
> \- Token path ?: C:\\Users\\Admin\\.cache\\huggingface\\token
> \- Has saved token ?: True
> \- FastAI: N/A
> \- Tensorflow: N/A
> \- Torch: 2.4.0
> \- Jinja2: 3.1.4
> \- Graphviz: N/A
> \- keras: N/A
> \- Pydot: N/A
> \- Pillow: 10.4.0
> \- hf\_transfer: N/A
> \- gradio: N/A
> \- tensorboard: N/A
> \- numpy: 1.26.4
> \- pydantic: N/A
> \- aiohttp: N/A
> \- ENDPOINT: https://huggingface.co
> \- HF\_HUB\_CACHE: C:\\Users\\Admin\\.cache\\huggingface\\hub
> \- HF\_ASSETS\_CACHE: C:\\Users\\Admin\\.cache\\huggingface\\assets
> \- HF\_TOKEN\_PATH: C:\\Users\\Admin\\.cache\\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
> \`\`\`

---

<div class="post-metadata">

**Author:** ![hlinvest](https://avatars.discourse-cdn.com/v4/letter/h/8491ac/32.png) [@hlinvest](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fhlinvest)%5C
**Post date:** [February 25, 2025, 3:41pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finvalid-token-or-no-access-to-hugging-face%2F115807%2F3 "2025-02-25T15:41:31Z")

</div>

Dont paste the token with ctrl+p, right click to paste it.

---

<div class="post-metadata">

**Author:** ![BenjaminKam](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/benjaminkam/32/48457_2.png) [@BenjaminKam](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FBenjaminKam)%5C
**Post date:** [May 29, 2025, 9:21am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finvalid-token-or-no-access-to-hugging-face%2F115807%2F4 "2025-05-29T09:21:33Z")

</div>

Oh my days thank you so much
