Supabase Google Oauth

Hi all,
I’ve seen this useful post on Supabase auth: Supabase-ui login component in Streamlit

I was wondering if anyone has implemented Supabase Oauth for Google?

I’ve seen this library, but it doesn’t seem to work. (streamlit-supabase-auth · PyPI)

This is my app: https://pedagogical.app/

Thanks!
Phil

Hi Phil,

I decided to give this component a go and it actually works really well, except that I am still trying to figure out how to make the email and password functionality work. Maybe @sweatybridge can give us a few pointers on how to make it work.

import streamlit as st
from streamlit_supabase_auth import login_form, logout_button

st.set_page_config(page_title="Hello", page_icon="👋")
if not st.session_state.get('login'):
    # Display a landing page with an authorize button
    st.title("Welcome to .......")

######<SUPABASE OAUTH>#####
# Retrieve these values from your Supabase project settings
SUPABASE_URL = st.secrets['SUPABASE_URL']
SUPABASE_ANON_KEY = st.secrets['SUPABASE_ANON_KEY']

session = login_form(
     url=SUPABASE_URL,
     apiKey=SUPABASE_ANON_KEY,
     providers=["apple", "facebook", "github", "google"],
     )

# Display welcome message and user details
if session:
    user_name=session['user']['user_metadata'].get('name')
    avatar_url = session['user']['user_metadata'].get('avatar_url')
    email_verified = session['user']['user_metadata'].get('email_verified')
    if not email_verified:
        st.error("Please use a verified email address to log in.")
    else:
        # Additional logic for when the user is authenticated...
        st.write(f"Welcome {user_name}!")
        with st.sidebar:
                if user_name:  # Checking if user_name exists before attempting to display it
                    st.write(f"Welcome {user_name}!")
                if avatar_url:  # Similarly, check for avatar_url
                    st.image(avatar_url, width=100)
                logout_button(url=SUPABASE_URL, apiKey=SUPABASE_ANON_KEY)
######</SUPABASE OAUTH>#####

It opens your app in a new tab window whenever you authorize so you end up having to two tabs open. I wonder if we could program the second tab to automatically close once you are authenticated :thinking:

Anyways, hope this helps :+1:

Luis

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