uiucanh / streamlit-google-oauth

An example Streamlit application that incorporates Google OAuth 2.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logout link/button

hunkim opened this issue · comments

This is wonderful.

How to add a logout button/link?

I tried two ways:

async def revoke_token(token):
    return await  client.revoke_token(token)
    
if st.button(f"Logout from Google {user_email}"):
        revoke_token(token=st.session_state.token)
        st.session_state.user_email = None
        st.session_state.user_id = None
        st.session_state.token = None
        st.experimental_rerun()

and

    st.write(f'''
    <div align="right"><a target="_self" href="{authorization_url}">
        <button>
            Logout from Google {user_email}
        </button>
    </a></div>
    ''',
    unsafe_allow_html=True
    )
    

I guess the firstone is actually better.