Simple Streamlit Google OAuth

Using this wonderful code Implementing Google OAuth in Streamlit | by Duc Anh Bui | Towards Data Science, I refactor it to simply use as pip.

Just do:
pip install git+https://github.com/hunkim/streamlit-google-oauth

Then add login code:

login_info = oauth.login(
        client_id=client_id,
        client_secret=client_secret,
        redirect_uri=redirect_uri,
        login_button_text="Continue with Google",
        logout_button_text="Logout",
    )

if login_info:
        user_id, user_email = login_info
        st.write(f"Welcome {user_email}")
else:
        st.write("Please login")

That’s it.

Any comments, and contributions are welcome at GitHub - hunkim/streamlit-google-oauth: An example Streamlit application that incorporates Google OAuth 2.0.

Actually, these buttons are ugly. Please feel free to send us PR.

5 Likes