{"id":1734,"library":"supabase-auth","title":"Supabase Auth Client","description":"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.","status":"active","version":"2.28.3","language":"en","source_language":"en","source_url":"https://github.com/supabase-community/supabase-auth-py","tags":["supabase","authentication","auth","jwt","client"],"install":[{"cmd":"pip install supabase-auth","lang":"bash","label":"Install supabase-auth"}],"dependencies":[],"imports":[{"note":"AuthClient is located in the 'client' submodule.","wrong":"from supabase_auth import AuthClient","symbol":"AuthClient","correct":"from supabase_auth.client import AuthClient"},{"note":"User and other type definitions are in the 'types' submodule.","wrong":"from supabase_auth import User","symbol":"User","correct":"from supabase_auth.types import User"}],"quickstart":{"code":"import os\nfrom supabase_auth.client import AuthClient\n\n# Ensure these environment variables are set\nSUPABASE_URL = os.environ.get('SUPABASE_URL', 'YOUR_SUPABASE_URL')\nSUPABASE_ANON_KEY = os.environ.get('SUPABASE_ANON_KEY', 'YOUR_SUPABASE_ANON_KEY')\n\nif SUPABASE_URL == 'YOUR_SUPABASE_URL' or SUPABASE_ANON_KEY == 'YOUR_SUPABASE_ANON_KEY':\n    print(\"Please set SUPABASE_URL and SUPABASE_ANON_KEY environment variables.\")\nelse:\n    try:\n        auth_client = AuthClient(SUPABASE_URL, SUPABASE_ANON_KEY)\n\n        # Example: Sign up a new user\n        # Replace with unique email/password for testing\n        user_email = 'test@example.com'\n        user_password = 'strong-password'\n\n        # try:\n        #     response = auth_client.sign_up(user_email, user_password)\n        #     print(\"Sign up response:\", response.user)\n        #     print(\"Session:\", response.session)\n        # except Exception as e:\n        #     print(f\"Sign up failed (might already exist): {e}\")\n\n        # Example: Sign in an existing user\n        try:\n            response = auth_client.sign_in(user_email, user_password)\n            print(\"Sign in successful! User ID:\", response.user.id)\n            print(\"Access Token:\", response.session.access_token)\n        except Exception as e:\n            print(f\"Sign in failed: {e}\")\n\n        # Example: Get current user details (requires active session)\n        if 'response' in locals() and response.session:\n            try:\n                current_user_response = auth_client.get_user(response.session.access_token)\n                print(\"Current user email:\", current_user_response.user.email)\n            except Exception as e:\n                print(f\"Failed to get user details: {e}\")\n\n    except Exception as e:\n        print(f\"An error occurred during client initialization or operation: {e}\")\n","lang":"python","description":"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."},"warnings":[{"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.","message":"When 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`.","severity":"breaking","affected_versions":"supabase-py < 2.0.0 (indirectly affected `supabase-auth` usage patterns)"},{"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.","message":"Properly 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Incorrectly 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').","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}