# Testing hugging face in langchain vs code

**URL:** <https://discuss.huggingface.co/t/testing-hugging-face-in-langchain-vs-code/158990>\
**Category:** Models\
**Created:** [June 12, 2025, 12:36am UTC](https://discuss.huggingface.co/t/testing-hugging-face-in-langchain-vs-code/158990 "2025-06-12T00:36:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anandtiwari91](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@anandtiwari91](https://discuss.huggingface.co/u/anandtiwari91)\
**Post date:** [June 12, 2025, 12:36am UTC](https://discuss.huggingface.co/t/testing-hugging-face-in-langchain-vs-code/158990/1 "2025-06-12T00:36:38Z")

</div>

Hi Group,

I am learning lang chain and hugging face. I’m using vs code as my IDE for test purposes. I am using the huggingfaceendpoint library and chathugging face libraries. I store the hugging face token in my .env file. Every time I run my python script and invoke the model in the script. I get the authorization header invalid.  
the same code when I run on google colab by saving the access token in the secret key, It works fine. Can somebody please help or let me know if you need any other information?

---

<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:** [June 12, 2025, 3:40am UTC](https://discuss.huggingface.co/t/testing-hugging-face-in-langchain-vs-code/158990/2 "2025-06-12T03:40:55Z")

</div>

If it works in Colab, then you’re probably just failing to pass the token. In that case, set the `HF_TOKEN` environment variable or write` login()` in the Python code to be sure. Don’t forget to install the library beforehand.

```auto
pip install -U huggingface_hub

```

> [@Huggingface cli login error](https://discuss.huggingface.co/t/huggingface-cli-login-error/157361):
>
> logging in with access token stopped working (had no issues before), tried with 3 different tokens + on different huggingface\_hub envs, exact error trace is this Traceback (most recent call last): File “C:\comfyenv\Lib\site-packages\huggingface\_hub\utils\_http.py”, line 409, in hf\_raise\_for\_status response.raise\_for\_status() File “C:\comfyenv\Lib\site-packages\requests\models.py”, line 1024, in raise\_for\_status raise HTTPError(http\_error\_msg, response=self) requests.exceptions.HTTPError: 40…

> **[User access tokens](https://huggingface.co/docs/hub/security-tokens)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> **[Environment variables](https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![anandtiwari91](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@anandtiwari91](https://discuss.huggingface.co/u/anandtiwari91)\
**Post date:** [June 19, 2025, 5:11am UTC](https://discuss.huggingface.co/t/testing-hugging-face-in-langchain-vs-code/158990/3 "2025-06-19T05:11:46Z")

</div>

Thanks ! HF\_TOKEN solved the problem. Much appreciated!
