Get current user
This recipe gets information about the user accessing this Databricks App from their HTTP headers.
Code snippet
app.py
import streamlit as st
headers = st.context.headers
email = headers.get("X-Forwarded-Email")
username = headers.get("X-Forwarded-Preferred-Username")
user = headers.get("X-Forwarded-User")
ip = headers.get("X-Real-Ip")
st.write(f"E-mail: {email}, username: {username}, user: {user}, ip: {ip}")
Permissions
No permissions configuration required.
Dependencies
- Streamlit -
streamlit
requirements.txt
streamlit