liveBook · Manning

St.user

As explained in Build Python Web Apps with Streamlit

st.user is Streamlit's object for accessing the authenticated user's identity information and login status.

st.user lets a Streamlit app inspect the authenticated user's identity and login status after an OpenID Connect login. Check st.user.is_logged_in to determine whether access is authenticated, or read st.user.email to identify the user. section 8.4.3

Check authentication status

import streamlit as st if st.user.is_logged_in: st.write(f"Signed in as {st.user.email}") else: st.write("Please log in") section 8.4.3

Use st.user as part of Streamlit's OIDC authentication flow:

  • Configure an OIDC-supported identity provider such as Google, Microsoft, Okta, or Auth0, storing the client details and metadata in st.secrets. section 8.4.3
  • Start authentication with st.login, then inspect st.user in the app; end the session with st.logout. section 8.4.3
  • For Streamlit 1.44.0 or earlier, the corresponding object may be named st.experimental_user. section 8.4.3

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains status and email access plus surrounding login configuration, but does not detail authentication internals.
Examples
Uses login-state checks, email display, Google authentication, and logout as concrete applications.
What it assumes
Requires an OIDC identity-provider account and client configuration, while defining login-status and email access directly.
What you can do after
Apply it via Streamlit to detect authenticated users and display their email addresses.
How it connects
Connects st.user with OpenID Connect, identity providers, st.login, st.logout, and st.secrets.

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.