# Need Help Utilizing Gradio Auth page on HF space

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-utilizing-gradio-auth-page-on-hf-space%2F80085%3E%5C
**Category:** Beginners\
**Created:** [April 4, 2024, 3:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-utilizing-gradio-auth-page-on-hf-space%2F80085 "2024-04-04T03:01:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prismglider](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@prismglider](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fprismglider)%5C
**Post date:** [April 4, 2024, 3:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-utilizing-gradio-auth-page-on-hf-space%2F80085%2F1 "2024-04-04T03:01:42Z")

</div>

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](https://huggingface.co/spaces/mikeee/ttw))

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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-persist-gradio-authentication-username-information-on-the-next-page-after-login%2F56674))

---

<div class="post-metadata">

**Author:** ![akuysal](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/akuysal/32/23405_2.png) [@akuysal](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fakuysal)%5C
**Post date:** [April 4, 2024, 3:36am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-utilizing-gradio-auth-page-on-hf-space%2F80085%2F2 "2024-04-04T03:36:19Z")

</div>

Last time I asked a similar question on [How to persist Gradio authentication username information on the next page after login](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-persist-gradio-authentication-username-information-on-the-next-page-after-login%2F56674) URL, I didn’t get a reply and the options I tried didn’t work. It was an optional thing that I was planning to do. So, I didn’t search for later solutions. It was a long time ago, so probably there may be some other recent solutions. But, at that time, I couldn’t find.

---

<div class="post-metadata">

**Author:** ![prismglider](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@prismglider](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fprismglider)%5C
**Post date:** [April 5, 2024, 6:01pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-utilizing-gradio-auth-page-on-hf-space%2F80085%2F3 "2024-04-05T18:01:14Z")

</div>

Hey so I was overcomplicating this a lot because of a different bug that I was encountering (gradio auth page is not working in safari or some private tabs).

global credentials{}  
credentials[username] = pass

This is to save the password of the login.

Then you can look up the auth username anytime with/

Function(request : gr.Request)  
request.username

and you can get the password/token back with  
credentials[request.username]

good luck!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [April 6, 2024, 6:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-utilizing-gradio-auth-page-on-hf-space%2F80085%2F4 "2024-04-06T06:01:23Z")

</div>

Closed on April 6, 2024, 6:01am UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
