September 10, 2022, 7:08am
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.
hf_api = huggingface_hub.HfApi()
Hey there! There are 3 ways
huggingface-cli login in the terminal
I hope this helps
September 23, 2022, 2:46pm
@sachin, the preferred way to login is to use
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
use_auth_token arguments in the
@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.
@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. 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.