Supabase Auth (Python)
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().
Warnings
- breaking supabase.auth.sign_in() is removed. All pre-2.0 tutorials use sign_in(). The correct method is sign_in_with_password(). Calling sign_in() raises AttributeError.
- breaking The standalone auth package was named 'gotrue' (pip install gotrue), then renamed to 'supabase-auth'. 'from gotrue import' raises ModuleNotFoundError if only supabase-auth is installed.
- breaking Admin auth methods (list_users, create_user, delete_user) require the service_role key, NOT the anon key. Using the anon key returns 403. The distinction is not obvious — both keys look identical in format.
- breaking sign_up() returns (user, session) where session is None if email confirmation is enabled (the default). Code that immediately uses res.session.access_token will raise AttributeError: 'NoneType' object has no attribute 'access_token'.
- breaking Realtime subscriptions only work with the async client (acreate_client). The sync client silently ignores realtime calls or raises errors.
- gotcha SUPABASE_KEY should be the anon key for user-facing operations. The service_role key bypasses Row Level Security entirely — accidental use in client-side code exposes all data.
- gotcha Default row limit is 1000 rows. Queries that return more than 1000 rows are silently truncated with no error. Agents building data pipelines hit this constantly.
- gotcha supabase.auth.admin is only accessible when the client was initialized with the service_role key. Calling admin methods with the anon key returns 403 with 'not authorized' — not a clear 'wrong key' error.
Install
-
pip install supabase -
pip install supabase-auth
Imports
- create_client
from supabase import create_client, Client
- SyncGoTrueClient
from supabase_auth import SyncGoTrueClient
Quickstart
import os
from supabase import create_client, Client
url: str = os.environ['SUPABASE_URL']
key: str = os.environ['SUPABASE_KEY'] # anon key for client-side, service_role for admin
supabase: Client = create_client(url, key)
# Sign up
res = supabase.auth.sign_up({
'email': 'user@example.com',
'password': 'securepassword'
})
# Sign in — NOT sign_in(), use sign_in_with_password()
res = supabase.auth.sign_in_with_password({
'email': 'user@example.com',
'password': 'securepassword'
})
print(res.user)
print(res.session.access_token)
# Admin operations — requires service_role key
res = supabase.auth.admin.list_users()
for user in res:
print(user.email)