Add "Sign in with Hugging Face" button (+ remove login() use)

#5
by Wauplin HF staff - opened

What for?

  1. 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.
  2. 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. Since login() 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 pass token=token to each individual method.
  3. Updating demo from gr.Interface to gr.Blocks style. gr.Interface is nice but adding a LoginButton 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).

Owner

What's this for?

@Weyaxi Sorry, the PR wasn't complete yet. I've updated the PR description to explain it!

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

Sign up or log in to comment