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
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.