Add "Sign in with Hugging Face" button (+ remove login() use)
#5
by
Wauplin
HF staff
- opened
What for?
- This PR adds a "Sign in with Hugging Face" button to the Space. The goal is that the user doesn't need to copy-paste their HF token. They only have to "sign in", authorize the Space to behave on their name and that's it. The Space then uses the temporary user token (provided by the Hub after the user accepted it) to download the readme file + open the PR on the user's name.
- Make the login process more robust. The
login()
line is good to use on a local setup (your laptop, a google colab, etc.) but not in this case. The danger is that 2 users try to use your Space at the same time. Sincelogin()
is storing the user's token on the Space hardware, if 2 users are creating a PR at the same time, both PRs will be open with the account of the second users. To avoid this, we now passtoken=token
to each individual method. - Updating demo from
gr.Interface
togr.Blocks
style.gr.Interface
is nice but adding aLoginButton
to it is not possible.
[Disclaimer]: I did not test this PR locally. Should be fine though (I took inspiration from https://huggingface.co/spaces/Wauplin/gradio-space-ci/ that I've recently updated for this exact same purpose).
What's this for?
Wauplin
changed pull request title from
[WIP]
to Add "Sign in with Hugging Face" button (+ remove login() use)
Weyaxi
changed pull request status to
merged