Login without `notebook_login`

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.

import huggingface_hub

hf_api = huggingface_hub.HfApi()

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

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. 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?)

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