Skip to main content

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

  1. Go to your Supabase Dashboard
  2. Navigate to Authentication → Providers
  3. Enable your OAuth provider (e.g., Google)
  4. Configure redirect URLs:
    • Add http://localhost:8501 for local development
    • Add your production URL for deployment

2. Configure Google OAuth (Example)

  1. Go to Google Cloud Console
  2. Create OAuth 2.0 Client ID
  3. Add authorized redirect URI: https://YOUR_PROJECT.supabase.co/auth/v1/callback
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_supabase_auth_flow-0.0.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_supabase_auth_flow-0.0.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_supabase_auth_flow-0.0.2.tar.gz.

File metadata

File hashes

Hashes for streamlit_supabase_auth_flow-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a47824d11373749d805ed8f8fcdc8c8a22ba0d49e4ec28eccdfe7a35c04d6792
MD5 39adf2fe8ad77f02b12b763619eaee4b
BLAKE2b-256 787da8c92b351ef1f6ed709e4995f492a0df223bf72452af0e2669c6b57b4334

See more details on using hashes here.

File details

Details for the file streamlit_supabase_auth_flow-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_supabase_auth_flow-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64c4f4a4fcf083009de3a32d4a5f2714cc36c5673c8e7b80a335a9949592d8a5
MD5 438ff9947b2052bbe289b31d975a24b1
BLAKE2b-256 1a693e0c49ff32f2845cb68ac29ccff781075b5d29786697aa28fdf5b0524d11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page