import gradio as gr
def greet_user(profile: gr.OAuthProfile | None):
if profile is None:
return "You are not logged in yet.\n\nPlease use the **Sign In** button above."
return (
f"Welcome, User!\n\nYou have successfully logged in"
)
with gr.Blocks() as demo:
gr.Markdown("## Hugging Face OAuth Login Demo", elem_id="title")
with gr.Row():
login_btn = gr.LoginButton()
logout_html = gr.HTML(
"""
"""
)
output = gr.Markdown("Checking login status...")
demo.load(fn=greet_user, inputs=None, outputs=output)
demo.launch()