# Login without \`notebook\_login\`

**URL:** <https://discuss.huggingface.co/t/login-without-notebook-login/22922>\
**Category:** 🤗Hub\
**Created:** [September 10, 2022, 7:08am UTC](https://discuss.huggingface.co/t/login-without-notebook-login/22922 "2022-09-10T07:08:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sachin/32/26534_2.png) [@sachin](https://discuss.huggingface.co/u/sachin)\
**Post date:** [September 10, 2022, 7:08am UTC](https://discuss.huggingface.co/t/login-without-notebook-login/22922/1 "2022-09-10T07:08:20Z")

</div>

Hi! Just wondering if there was a way to login without the `notebook_login` or the cli option. So far I tried this, but I’m not sure if it is logging in as it’s meant to.

The aim is to upload the trained model after I’ve logged in.

```auto
import huggingface_hub

hf_api = huggingface_hub.HfApi()
hf_api.set_access_token(hf_token)

```

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](https://discuss.huggingface.co/u/osanseviero)\
**Post date:** [September 23, 2022, 2:10pm UTC](https://discuss.huggingface.co/t/login-without-notebook-login/22922/2 "2022-09-23T14:10:49Z")

</div>

Hey there! There are 3 ways

- Use `notebook_login`
- Use `huggingface-cli login` in the terminal
- Use the `HfApi().login()` method

I hope this helps

cc @Wauplin

---

<div class="post-metadata">

**Author:** ![Wauplin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/wauplin/32/40815_2.png) [@Wauplin](https://discuss.huggingface.co/u/Wauplin)\
**Post date:** [September 23, 2022, 2:46pm UTC](https://discuss.huggingface.co/t/login-without-notebook-login/22922/3 "2022-09-23T14:46:08Z")

</div>

Hi @sachin, the preferred way to login is to use `notebook_login()` or `huggingface-cli login`. For now, `hf_api.set_access_token(hf_token)` sets the token only for git credentials (this is more a legacy feature). It would really make sense if this method was also used to send the token in HTTP requests. Could you open an issue for that in [GitHub - huggingface/huggingface\_hub: All the open source things related to the Hugging Face Hub.](https://github.com/huggingface/huggingface_hub) describing how you would like this feature to work ?

In the meantime, if you want to use your account programmatically, you have to pass the token value  
as `token` or `use_auth_token` arguments in the `HfApi` methods.

@osanseviero As far as I know, there is no `HfApi().login()` method implemented (yet?)

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](https://discuss.huggingface.co/u/osanseviero)\
**Post date:** [September 23, 2022, 3:00pm UTC](https://discuss.huggingface.co/t/login-without-notebook-login/22922/4 "2022-09-23T15:00:26Z")

</div>

I know remembered `login()` was deprecated in favor of `set_access_token` in v0.7.

---

<div class="post-metadata">

**Author:** ![Wauplin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/wauplin/32/40815_2.png) [@Wauplin](https://discuss.huggingface.co/u/Wauplin)\
**Post date:** [October 21, 2022, 2:10pm UTC](https://discuss.huggingface.co/t/login-without-notebook-login/22922/5 "2022-10-21T14:10:45Z")

</div>

Hi @sachin , this was a quite requested feature so we implemented it in [Unified login/logout methods by Wauplin · Pull Request #1111 · huggingface/huggingface\_hub · GitHub](https://github.com/huggingface/huggingface_hub/pull/1111). See PR description for how to use it.

This will be part of next `huggingface_hub` release. Otherwise you can also install from the `main` branch with `pip uninstall huggingface_hub && pip install git+https://github.com/huggingface/huggingface_hub`.
