I’m trying to implement basic username/password authentication in a Gradio app. It works locally but fails in HF Space.
# Basic auth configuration
app.launch(
auth=(username, password), # username/password from env vars
show_api=False
)
Environment variables are properly set in Space as secrets (APP_USER, APP_PSWD).
This is the error I am getting:
Error: Login credentials are required to access this space.
ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost.
What’s the correct way to implement basic auth in a Gradio app on HF Spaces?
From the error message, it seems that it should work just by passing share=True in .launch(), but in the first place, a normal Space works with share=False or the default without any options.
I don’t know why it needs to be set…
Mmmm, thank you for the response, I changed it to share = True and I get this:
/usr/local/lib/python3.10/site-packages/gradio/blocks.py:2596: UserWarning: Setting share=True is not supported on Hugging Face Spaces
warnings.warn(
...
I think it’s safe to ignore that warning. It doesn’t interfere with the operation. In fact, it seems to be in a running state.
The problem is the 500 error that is currently occurring, but this is a little unusual. There is a possibility that it is similar to the Tonic issue below. I hope it’s a problem that can be dealt with by the author’s side alone…
This error has occurred twice, and the last time it was due to a faulty network cluster. This time, the cause is still unknown.