Registry / auth-security / supabase-auth

supabase-auth

JSON →
library2.31.0pypypi✓ verified 25d ago

The `supabase-auth` Python library provides a client for interacting with Supabase Auth services, enabling functionalities like user registration, login, session management, and password recovery. It's a foundational component often used directly or as part of the `supabase-py` full client library. The current version is 2.28.3, and it follows the release cadence of the broader Supabase Python ecosystem, with frequent updates.

pip install supabase-auth
INSTALL
IMPORT
SIG · SUPABASE-AUTH
S
supabase-auth
auth-securitypythonv2.31.0
Install
5.0s avg
Import
820ms
Disk
49MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.31.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.862s · 50.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.0s · import 0.778s · 50MB
49MB installed
● package 49MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AsyncGoTrueClient
from supabase_auth import AsyncGoTrueClient
from supabase_auth.client import AuthClient
AsyncGoTrueAdminAPI
from supabase_auth import AsyncGoTrueAdminAPI
AuthChangeEvent
from supabase_auth import AuthChangeEvent

Initializes the `AuthClient` with your Supabase URL and anon key, then demonstrates basic user sign-up and sign-in operations. Remember to replace placeholder environment variables with your actual Supabase project credentials. Sign-up is commented out to prevent repeated user creation.

import os from supabase_auth.client import AuthClient # Ensure these environment variables are set SUPABASE_URL = os.environ.get('SUPABASE_URL', 'YOUR_SUPABASE_URL') SUPABASE_ANON_KEY = os.environ.get('SUPABASE_ANON_KEY', 'YOUR_SUPABASE_ANON_KEY') if SUPABASE_URL == 'YOUR_SUPABASE_URL' or SUPABASE_ANON_KEY == 'YOUR_SUPABASE_ANON_KEY': print("Please set SUPABASE_URL and SUPABASE_ANON_KEY environment variables.") else: try: auth_client = AuthClient(SUPABASE_URL, SUPABASE_ANON_KEY) # Example: Sign up a new user # Replace with unique email/password for testing user_email = 'test@example.com' user_password = 'strong-password' # try: # response = auth_client.sign_up(user_email, user_password) # print("Sign up response:", response.user) # print("Session:", response.session) # except Exception as e: # print(f"Sign up failed (might already exist): {e}") # Example: Sign in an existing user try: response = auth_client.sign_in(user_email, user_password) print("Sign in successful! User ID:", response.user.id) print("Access Token:", response.session.access_token) except Exception as e: print(f"Sign in failed: {e}") # Example: Get current user details (requires active session) if 'response' in locals() and response.session: try: current_user_response = auth_client.get_user(response.session.access_token) print("Current user email:", current_user_response.user.email) except Exception as e: print(f"Failed to get user details: {e}") except Exception as e: print(f"An error occurred during client initialization or operation: {e}")
Debug
Known issues
breakingWhen migrating from `supabase-py` v1 to v2, the internal `AuthClient` structure and interaction patterns significantly changed. If you previously accessed authentication functionality via `supabase.auth` in `supabase-py` v1 and are now using this standalone `supabase-auth` package or `supabase-py` v2, be aware of method signature changes and the explicit need to import `AuthClient` from `supabase_auth.client`.
fix
Review the official `supabase-auth-py` and `supabase-py` v2 documentation. Ensure you're importing `AuthClient` from `supabase_auth.client` and adapting method calls (e.g., `sign_up`, `sign_in`) to the current API.
affects: supabase-py < 2.0.0 (indirectly affected `supabase-auth` usage patterns)
gotchaProperly managing user sessions and token refreshing is crucial for long-lived applications. While `AuthClient` can handle token refreshing, incorrect configuration or manual management can lead to expired sessions and unauthorized requests.
fix
Ensure that `AuthClient` is configured to handle session refreshing or implement your own robust session management logic, including storing and refreshing tokens. The `supabase-py` client's `auth` property often abstracts some of this, but if using `supabase-auth` standalone, explicit handling might be required.
affects: All versions
gotchaIncorrectly setting `SUPABASE_URL` and `SUPABASE_ANON_KEY` or having misconfigured RLS (Row Level Security) policies on your Supabase project can lead to `AuthApiError` exceptions (e.g., 'Invalid API key' or 'Permission denied').
fix
Double-check your environment variables and ensure they match your Supabase project settings. For RLS issues, verify that your database policies allow the intended operations for authenticated and unauthenticated users.
affects: All versions
Upgrade
Version history
2.31.0latest on PyPI · released Jun 4, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
supabase-auth — pip install supabase-auth · libregistry