How to retrieve user's username after authenticating in Gradio

732 Views Asked by At

I have a gradio app with a custom login function. I was successful in doing authentication, but then I would like to retrieve and keep the user's username during the session. What would be the solution?

import gradio as gr

def login(email, password):
    """Custom authentication."""

    # Do stuff here
    return True, email

# Application layout
with gr.Blocks(title="My App") as app:
    with gr.Row():
        text = gr.Textbox(label="Text", placeholder="Hello world")

if __name__ == "__main__":
    app.launch(server_name="0.0.0.0", auth=login)
0

There are 0 best solutions below