OAuth component for Streamlit

Hello all :wave:
I created a Python-only component that handles OAuth authentication to Streamlit apps. The component will “gate” your app until the user successfully authenticates with the OAuth provider. It’s as simple as:

import streamlit as st
from st_oauth import st_oauth

st.markdown("## This (and above) is always seen")
id = st_oauth('myoauth', 'Click to login via OAuth')
st.markdown("## This (and below) is only seen after authentication")

It supports multi-page apps and query parameters, as well!
I also wrote a brief blog post on how to use it: OAuth Component for Streamlit. One of the common requests I get when… | by Brian Hess | Streamlit | Apr, 2023 | Medium

Check out the GitHub repo here: GitHub - sfc-gh-bhess/st_oauth: OAuth component for Streamlit


Hi @brianmhess , thanks for making this - very helpful ! For me somehow after I first time login to Okta from the app, it lands to the Okta admin dashboard instead of redirecting to the application as mentioned in redirect_uri as mentioned in secrets.toml or sign-in redirect APIs as configured in Okta (which is: http://localhos:8080/sample_app in both cases).

Next time in the same browser I open http://localhos:8080/sample_app, it correctly logs me in via okta as the token is there in browser. I am not sure why after first time login it does not redirect me to the redirect_uri … any idea?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.