# ValueError: Error 400: {'error': 'Authorization header is correct, but the token seems invalid'}

**URL:** <https://discuss.huggingface.co/t/valueerror-error-400-error-authorization-header-is-correct-but-the-token-seems-invalid/69677>\
**Category:** Beginners\
**Created:** [January 18, 2024, 7:08pm UTC](https://discuss.huggingface.co/t/valueerror-error-400-error-authorization-header-is-correct-but-the-token-seems-invalid/69677 "2024-01-18T19:08:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![men-can](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@men-can](https://discuss.huggingface.co/u/men-can)\
**Post date:** [January 18, 2024, 7:08pm UTC](https://discuss.huggingface.co/t/valueerror-error-400-error-authorization-header-is-correct-but-the-token-seems-invalid/69677/1 "2024-01-18T19:08:04Z")

</div>

Hi there very new to huggingface and I am trying to run transformers agent however, I keep getting the error below. Any help on this would be greatly appreciated.

```auto
import os
from scripts.global_var import config

default_home = os.path.join(os.getcwd(), ".cache")
hf_cache_home = os.path.join(default_home, "huggingface")
os.environ["HF_HOME"] = hf_cache_home
os.environ["HF_TOKEN_PATH"] = os.path.join(hf_cache_home, "token")
from huggingface_hub import login

login(config["huggingface_api"])
from transformers import HfAgent

agent_star = HfAgent(
    "https://api-inference.huggingface.co/models/bigcode/starcoder"
)
text = "this is new building with 14 storeys painted green."
storey_1 = agent_star.run("What is the number of storeys?", text=text)

```

```auto
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\Users\tolu.olusooto\Documents\Nakina\.venv\lib\site-packages\transformers\tools\agents.py", line 341, in run
    result = self.generate_one(prompt, stop=["Task:"])
  File "c:\Users\tolu.olusooto\Documents\Nakina\.venv\lib\site-packages\transformers\tools\agents.py", line 649, in generate_one
    raise ValueError(f"Error {response.status_code}: {response.json()}")
ValueError: Error 400: {'error': 'Authorization header is correct, but the token seems invalid'}

```

---

<div class="post-metadata">

**Author:** ![vedamsudhakar](https://avatars.discourse-cdn.com/v4/letter/v/cdc98d/32.png) [@vedamsudhakar](https://discuss.huggingface.co/u/vedamsudhakar)\
**Post date:** [May 20, 2024, 1:06am UTC](https://discuss.huggingface.co/t/valueerror-error-400-error-authorization-header-is-correct-but-the-token-seems-invalid/69677/2 "2024-05-20T01:06:46Z")

</div>

Please update the permissions of the token to write/read, which can solve the problem.
