Community Cloud authentication: is X-Streamlit-User a supported fallback?

Hey there!

I’m building an app that uses my own OIDC provider for authentication via st.user, but I also deploy it on Streamlit Community Cloud.

I noticed that when a private app is accessed through Community Cloud, st.user is empty (as documented), but st.context.headers contains an X-Streamlit-User header with the authenticated Community Cloud user information.

The documentation states that, starting with Streamlit 1.42.0, st.user no longer exposes the Community Cloud account email, and this change appears to have been introduced in this documentation PR:

This raises two questions:

  1. Is X-Streamlit-User considered a trusted and stable interface that applications can safely use as a fallback authentication mechanism on Community Cloud, or is it strictly an internal implementation detail that should not be relied upon?

  2. What was the rationale behind the decision to stop populating st.user with the authenticated Community Cloud user? Was it driven primarily by security, privacy, architectural considerations, or something else?

My use case is to avoid asking users to authenticate twice when they have already authenticated with Community Cloud, while also avoiding reliance on undocumented behavior if it isn’t intended for application use.

I’d appreciate any clarification on whether X-Streamlit-User is considered safe to use, and whether there are any plans to expose the Community Cloud identity through a supported public API in the future.

Thanks in advance.

Welcome to the community and thanks for your thoughtful question! :tada: You’re absolutely right: as of Streamlit 1.42.0, st.user no longer exposes the Community Cloud account email, and this is now the documented and intended behavior. The rationale for this change was primarily privacy and security—ensuring that user identity information is only available when an explicit authentication flow (via OIDC and st.login) is configured by the app developer, rather than being implicitly exposed by the platform. This helps prevent accidental data leaks and aligns with best practices for user data handling. For more details, see the Streamlit API docs and related GitHub issue.

Regarding the X-Streamlit-User header in st.context.headers: this is not a documented or stable public API. It is considered an internal implementation detail and should not be relied upon for authentication or user identification in your apps. The Streamlit team may change or remove this header at any time without notice, and there are no guarantees about its format or presence. If you need to access user identity on Community Cloud, the only supported and stable approach is to configure your own OIDC provider and use st.login/st.user. There are currently no plans to re-expose Community Cloud identity through a public API, but you can follow feature discussions for updates.

Sources: