# Authorization header is correct, but the token seems invalid

**URL:** <https://discuss.huggingface.co/t/authorization-header-is-correct-but-the-token-seems-invalid/111177>\
**Category:** 🤗Tokenizers\
**Created:** [October 10, 2024, 12:02pm UTC](https://discuss.huggingface.co/t/authorization-header-is-correct-but-the-token-seems-invalid/111177 "2024-10-10T12:02:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DiegoHexagon](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@DiegoHexagon](https://discuss.huggingface.co/u/DiegoHexagon)\
**Post date:** [October 10, 2024, 12:02pm UTC](https://discuss.huggingface.co/t/authorization-header-is-correct-but-the-token-seems-invalid/111177/1 "2024-10-10T12:02:42Z")

</div>

Hello,

I read more solutions for this problem, but no one is valid for me.

I use huggingface with nodejs.

Also with a simple code I have the error.

const { HfInference } = require(‘@huggingface/inference’);

const hf = new HfInference({ token: ‘hf\_…’ }); //  
await hf.featureExtraction({  
model: “sentence-transformers/distilbert-base-nli-mean-tokens”,  
inputs: “That is a happy person”,  
});

I checked

Write access to contents/settings of all repos under your personal namespace  
Make calls to the serverless Inference API

in ther option of the AccessToken

Maybe someone can help me.

---

<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:** [October 10, 2024, 12:38pm UTC](https://discuss.huggingface.co/t/authorization-header-is-correct-but-the-token-seems-invalid/111177/2 "2024-10-10T12:38:48Z")

</div>

I’m not familiar with JavaScript, but let’s follow the sample anyway. Sometimes a model is bad, so you can try a different one.

> **[Hugging Face JS libraries](https://huggingface.co/docs/huggingface.js/index)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> **[Accessing Private/Gated Models](https://huggingface.co/docs/transformers.js/guides/private)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![DiegoHexagon](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@DiegoHexagon](https://discuss.huggingface.co/u/DiegoHexagon)\
**Post date:** [October 10, 2024, 1:25pm UTC](https://discuss.huggingface.co/t/authorization-header-is-correct-but-the-token-seems-invalid/111177/3 "2024-10-10T13:25:13Z")

</div>

Thanks for reply.  
I have to use the first model for my solution

---

<div class="post-metadata">

**Author:** ![DiegoHexagon](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@DiegoHexagon](https://discuss.huggingface.co/u/DiegoHexagon)\
**Post date:** [October 10, 2024, 2:02pm UTC](https://discuss.huggingface.co/t/authorization-header-is-correct-but-the-token-seems-invalid/111177/4 "2024-10-10T14:02:48Z")

</div>

Solved.  
The problem was that I used "const hf ", and this is noa accepted.  
I changed in “const inference” and now it works.
