Simple Supabase auth for streamlit using implicit flow.
Project description
Streamlit Supabase Auth Flow
Other streamlit supabase auth packages build a custom log in form in react and pass back to the streamlit app information about the user. This package uses the the IdP's implicit flow to authenticate the user, get's the token from the URL with a simple html component, and returns a user object. The client can be used to make database queries impersonating the user.
I used LLM's to create this, and although I made all the techinal decisions and used the LLM to speed things up, I might have missed something. Please raise an issue.
Installation
pip install streamlit-supabase-auth-flow
Quick Start
1. Configure Supabase
- Go to your Supabase Dashboard
- Navigate to Authentication → Providers
- Enable your OAuth provider (e.g., Google)
- Configure redirect URLs:
- Add
http://localhost:8501for local development - Add your production URL for deployment
- Add
2. Configure Google OAuth (Example)
- Go to Google Cloud Console
- Create OAuth 2.0 Client ID
- Add authorized redirect URI:
https://YOUR_PROJECT.supabase.co/auth/v1/callback - Copy Client ID and Secret to Supabase
3. Use in Your Streamlit App
import streamlit as st
from streamlit_supabase_auth_flow import SupabaseAuth
# Initialize auth
auth = SupabaseAuth(
supabase_url="https://your-project.supabase.co",
supabase_key="your-anon-key",
redirect_uri="http://localhost:8501"
)
# Check authentication status
if auth.is_authenticated():
user = auth.get_user()
st.write(f"Welcome {user.email}!")
if st.button("Logout"):
auth.logout()
else:
st.write("Please login to continue")
auth.login_button(provider="google")
Access Supabase Client
The underlying Supabase client is available for database operations:
if auth.is_authenticated():
# Access Supabase client
supabase = auth.client
# Query your database
response = supabase.table('todos').select('*').execute()
st.write(response.data)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_supabase_auth_flow-0.0.2.tar.gz.
File metadata
- Download URL: streamlit_supabase_auth_flow-0.0.2.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a47824d11373749d805ed8f8fcdc8c8a22ba0d49e4ec28eccdfe7a35c04d6792
|
|
| MD5 |
39adf2fe8ad77f02b12b763619eaee4b
|
|
| BLAKE2b-256 |
787da8c92b351ef1f6ed709e4995f492a0df223bf72452af0e2669c6b57b4334
|
File details
Details for the file streamlit_supabase_auth_flow-0.0.2-py3-none-any.whl.
File metadata
- Download URL: streamlit_supabase_auth_flow-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64c4f4a4fcf083009de3a32d4a5f2714cc36c5673c8e7b80a335a9949592d8a5
|
|
| MD5 |
438ff9947b2052bbe289b31d975a24b1
|
|
| BLAKE2b-256 |
1a693e0c49ff32f2845cb68ac29ccff781075b5d29786697aa28fdf5b0524d11
|