- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2024 10:21 PM
I have created a Databricks App using streamlit and able to deploy and use it successfully.
I need to get the user name/email address of the logged in user and display in the streamlit app. Is this possible?
If not possible at the moment, any roadmap for adding this feature?
regards,
--
satniks
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 06:01 AM
Yes, it is possible to retrieve and display the username or email address of the logged-in user in a Streamlit app deployed on Databricks. This can be achieved through two primary approaches:
1. Using "st.experimental_user" in streamlit.
import streamlit as st
# Access the user's email
user_email = st.experimental_user.get("email", "Unknown User")
# Display the email in the app st.write(f"Logged in as: {user_email}")
2. Using HTTP Headers in Databricks Apps.
import os
import streamlit as st
# Access headers passed by Databricks Apps
user_email = os.getenv("X-Forwarded-Email", "Unknown User")
# Display the user's email
st.write(f"Logged in as: {user_email}")
Hope this helps. Cheers, Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2024 04:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 06:01 AM
Yes, it is possible to retrieve and display the username or email address of the logged-in user in a Streamlit app deployed on Databricks. This can be achieved through two primary approaches:
1. Using "st.experimental_user" in streamlit.
import streamlit as st
# Access the user's email
user_email = st.experimental_user.get("email", "Unknown User")
# Display the email in the app st.write(f"Logged in as: {user_email}")
2. Using HTTP Headers in Databricks Apps.
import os
import streamlit as st
# Access headers passed by Databricks Apps
user_email = os.getenv("X-Forwarded-Email", "Unknown User")
# Display the user's email
st.write(f"Logged in as: {user_email}")
Hope this helps. Cheers, Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2024 10:30 PM
X-Forwarded-Email worked. I assume you mean using st.context.headers.get() instead of os.getenv().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2024 04:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2024 10:25 PM
Thanks @BigRoux and @Shannon_O for your response.
I tried st.experimental_user.get() API but it gives me hardcoded response as test@example.com
Suggestion to use X-Forwarded-Email header worked and I got correct email address. Thanks for your help. I am unblocked now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friday
I have also tried to deploy a streamlit app, however I was not able to deploy it.

