I’m having some trouble with a gradio HuggingFace space that uses the builtin Gradio auth page to pass a username and API token from a third party service.
How can I store each user’s token and username in a dict that is tied to the user’s login session? This is so I can look up their token/username later for doing API calls, without user’s accidentally using a previous user’s data.
My first solution was using a form of request.username to get a unique session, but this seemed to only be working when the user was logged in to HF. I cannot find a way to use the OS library to generate a unique session ID otherwise, but I tried several methods in this terminal (ttw - a Hugging Face Space by mikeee)
I then tried to get the current user’s IP but it seems like gr.Request is not available at time of login, I was not able to pass (request : gr.Request) while in the authentication step. The login page would succesfully take the credentials but would never load the app, it would get stuck.
I think I need to be using gr.State() with the token and username but the documentation on it’s utilization has been a bit confusing. An example of using it to store log in details passed through the builtin Auth page would be a big help.
This is similar to this issue ftr (How to persist Gradio authentication username information on the next page after login)