Official Supabase Python client. Current version is 2.28.2 (Mar 2026). Auth is accessed via supabase.auth — not a separate install. The underlying auth library was renamed twice: gotrue-py → auth-py → supabase-auth. The standalone package is 'supabase-auth' (imports as 'supabase_auth'). Most auth is used through the main 'supabase' package via create_client(). Massive tutorial corpus uses the old sign_in() method removed in favor of sign_in_with_password().
pip install supabaseVerified import paths — ran on the pinned version, not inferred.
Client initialization and auth operations using supabase v2.x.
Replace supabase.auth.sign_in({'email': ..., 'password': ...}) with supabase.auth.sign_in_with_password({'email': ..., 'password': ...})Replace 'from gotrue import' with 'from supabase_auth import'. Or just use the main supabase package which bundles auth.
For admin ops: create_client(url, os.environ['SUPABASE_SERVICE_ROLE_KEY']). Never expose service_role key to the client/browser.
Check: if res.session is not None before accessing access_token. Or disable email confirmation in Supabase dashboard for dev environments.
Use acreate_client() for any code that needs realtime. sync create_client() is for REST/auth only.
Use anon key (SUPABASE_ANON_KEY) for client operations. Use service_role key only in server-side admin contexts.
Use .range(start, end) for pagination or increase the limit in Supabase project API settings.
Maintain two client instances: one with anon key for user operations, one with service_role key for admin operations.
Ensure `SUPABASE_URL` and `SUPABASE_ANON_KEY` (and `SUPABASE_SERVICE_ROLE_KEY` if performing admin operations) are set as environment variables. Alternatively, pass the URL and key values directly to `create_client()`.
Ensure SUPABASE_URL and SUPABASE_KEY (or SUPABASE_ANON_KEY) environment variables are set before initializing the Supabase client.
client.auth.sign_in_with_password(email="user@example.com", password="your_password")
import os
from supabase import create_client
supabase_url = os.environ.get("SUPABASE_URL")
supabase_key = os.environ.get("SUPABASE_KEY")
supabase = create_client(supabase_url, supabase_key)Examine the specific error message that follows `PostgrestAPIError` in the traceback to diagnose the issue; common solutions include verifying table/column names, checking data types, ensuring unique constraints, or reviewing Row Level Security (RLS) policies in your Supabase project.
Remove `import gotrue` or `from gotrue.sync import AuthClient`. Instead, use `from supabase import create_client` and access authentication via `supabase_client.auth`. If a standalone auth client is required, install `supabase-auth` and import `supabase_auth`.