supabase-auth


Namesupabase-auth JSON
Version 2.23.1 PyPI version JSON
download
home_pageNone
SummaryPython Client Library for Supabase Auth
upload_time2025-11-03 14:30:14
maintainerLeonardo Santiago
docs_urlNone
authorJoel Lee
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Auth-py

[![CI](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml/badge.svg)](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml)
[![Python](https://img.shields.io/pypi/pyversions/gotrue)](https://pypi.org/project/gotrue)
[![Version](https://img.shields.io/pypi/v/gotrue?color=%2334D058)](https://pypi.org/project/gotrue)

This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current state is that there is a features parity but with small differences that are mentioned in the section **Differences to the JS client**. As of December 14th, we renamed to repo from `gotrue-py` to `auth-py` to mirror the changes in the JavaScript library.

## Installation

The package can be installed using pip, uv or poetry:

### Pip

```bash
pip install supabase_auth
```


### Uv

```bash
uv add supabase_auth
```

### Poetry

```bash
poetry add supabase_auth
```

## Features

- Full feature parity with the JavaScript client
- Support for both synchronous and asynchronous operations
- MFA (Multi-Factor Authentication) support
- OAuth and SSO integration
- Magic link and OTP authentication
- Phone number authentication
- Anonymous sign-in
- Session management with auto-refresh
- JWT token handling and verification
- User management and profile updates

## Differences to the JS client

It should be noted there are differences to the [JS client](https://github.com/supabase/gotrue-js). If you feel particulaly strongly about them and want to motivate a change, feel free to make a GitHub issue and we can discuss it there.

Firstly, feature pairity is not 100% with the [JS client](https://github.com/supabase/gotrue-js). In most cases we match the methods and attributes of the [JS client](https://github.com/supabase/gotrue-js) and api classes, but is some places (e.g for browser specific code) it didn't make sense to port the code line for line.

There is also a divergence in terms of how errors are raised. In the [JS client](https://github.com/supabase/gotrue-js), the errors are returned as part of the object, which the user can choose to process in whatever way they see fit. In this Python client, we raise the errors directly where they originate, as it was felt this was more Pythonic and adhered to the idioms of the language more directly.

In JS we return the error, but in Python we just raise it.

```js
const { data, error } = client.sign_up(...)
```

The other key difference is we do not use pascalCase to encode variable and method names. Instead we use the snake_case convention adopted in the Python language.

Also, the `supabase_auth` library for Python parses the date-time string into `datetime` Python objects. The [JS client](https://github.com/supabase/gotrue-js) keeps the date-time as strings.

## Usage

The library provides both synchronous and asynchronous clients. Here are some examples:

### Synchronous Client

```python
from supabase_auth import SyncGoTrueClient

headers = {
    "apiKey": "my-mega-awesome-api-key",
    # ... any other headers you might need.
}
client: SyncGoTrueClient = SyncGoTrueClient(url="www.genericauthwebsite.com", headers=headers)

# Sign up with email and password
user = client.sign_up(email="example@gmail.com", password="*********")

# Sign in with email and password
user = client.sign_in_with_password(email="example@gmail.com", password="*********")

# Sign in with magic link
user = client.sign_in_with_otp(email="example@gmail.com")

# Sign in with phone number
user = client.sign_in_with_otp(phone="+1234567890")

# Sign in with OAuth
user = client.sign_in_with_oauth(provider="google")

# Sign out
client.sign_out()

# Get current user
user = client.get_user()

# Update user profile
user = client.update_user({"data": {"name": "John Doe"}})
```

### Asynchronous Client

```python
from supabase_auth import AsyncGoTrueClient

headers = {
    "apiKey": "my-mega-awesome-api-key",
    # ... any other headers you might need.
}
client: AsyncGoTrueClient = AsyncGoTrueClient(url="www.genericauthwebsite.com", headers=headers)

async def main():
    # Sign up with email and password
    user = await client.sign_up(email="example@gmail.com", password="*********")

    # Sign in with email and password
    user = await client.sign_in_with_password(email="example@gmail.com", password="*********")

    # Sign in with magic link
    user = await client.sign_in_with_otp(email="example@gmail.com")

    # Sign in with phone number
    user = await client.sign_in_with_otp(phone="+1234567890")

    # Sign in with OAuth
    user = await client.sign_in_with_oauth(provider="google")

    # Sign out
    await client.sign_out()

    # Get current user
    user = await client.get_user()

    # Update user profile
    user = await client.update_user({"data": {"name": "John Doe"}})

# Run the async code
import asyncio
asyncio.run(main())
```

### MFA Support

The library includes support for Multi-Factor Authentication:

```python
# List MFA factors
factors = client.mfa.list_factors()

# Enroll a new MFA factor
enrolled_factor = client.mfa.enroll({"factor_type": "totp"})

# Challenge and verify MFA
challenge = client.mfa.challenge({"factor_id": "factor_id"})
verified = client.mfa.verify({"factor_id": "factor_id", "code": "123456"})

# Unenroll a factor
client.mfa.unenroll({"factor_id": "factor_id"})
```

## Contributions

We would be immensely grateful for any contributions to this project.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "supabase-auth",
    "maintainer": "Leonardo Santiago",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Leonardo Santiago <leonardo.santiago@supabase.io>",
    "keywords": null,
    "author": "Joel Lee",
    "author_email": "Joel Lee <joel@joellee.org>",
    "download_url": "https://files.pythonhosted.org/packages/ae/22/23e93d551ebec1801b7424bdec3e8b3514d6335149b6ccf292f5d40e9a57/supabase_auth-2.23.1.tar.gz",
    "platform": null,
    "description": "# Auth-py\n\n[![CI](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml/badge.svg)](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml)\n[![Python](https://img.shields.io/pypi/pyversions/gotrue)](https://pypi.org/project/gotrue)\n[![Version](https://img.shields.io/pypi/v/gotrue?color=%2334D058)](https://pypi.org/project/gotrue)\n\nThis is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current state is that there is a features parity but with small differences that are mentioned in the section **Differences to the JS client**. As of December 14th, we renamed to repo from `gotrue-py` to `auth-py` to mirror the changes in the JavaScript library.\n\n## Installation\n\nThe package can be installed using pip, uv or poetry:\n\n### Pip\n\n```bash\npip install supabase_auth\n```\n\n\n### Uv\n\n```bash\nuv add supabase_auth\n```\n\n### Poetry\n\n```bash\npoetry add supabase_auth\n```\n\n## Features\n\n- Full feature parity with the JavaScript client\n- Support for both synchronous and asynchronous operations\n- MFA (Multi-Factor Authentication) support\n- OAuth and SSO integration\n- Magic link and OTP authentication\n- Phone number authentication\n- Anonymous sign-in\n- Session management with auto-refresh\n- JWT token handling and verification\n- User management and profile updates\n\n## Differences to the JS client\n\nIt should be noted there are differences to the [JS client](https://github.com/supabase/gotrue-js). If you feel particulaly strongly about them and want to motivate a change, feel free to make a GitHub issue and we can discuss it there.\n\nFirstly, feature pairity is not 100% with the [JS client](https://github.com/supabase/gotrue-js). In most cases we match the methods and attributes of the [JS client](https://github.com/supabase/gotrue-js) and api classes, but is some places (e.g for browser specific code) it didn't make sense to port the code line for line.\n\nThere is also a divergence in terms of how errors are raised. In the [JS client](https://github.com/supabase/gotrue-js), the errors are returned as part of the object, which the user can choose to process in whatever way they see fit. In this Python client, we raise the errors directly where they originate, as it was felt this was more Pythonic and adhered to the idioms of the language more directly.\n\nIn JS we return the error, but in Python we just raise it.\n\n```js\nconst { data, error } = client.sign_up(...)\n```\n\nThe other key difference is we do not use pascalCase to encode variable and method names. Instead we use the snake_case convention adopted in the Python language.\n\nAlso, the `supabase_auth` library for Python parses the date-time string into `datetime` Python objects. The [JS client](https://github.com/supabase/gotrue-js) keeps the date-time as strings.\n\n## Usage\n\nThe library provides both synchronous and asynchronous clients. Here are some examples:\n\n### Synchronous Client\n\n```python\nfrom supabase_auth import SyncGoTrueClient\n\nheaders = {\n    \"apiKey\": \"my-mega-awesome-api-key\",\n    # ... any other headers you might need.\n}\nclient: SyncGoTrueClient = SyncGoTrueClient(url=\"www.genericauthwebsite.com\", headers=headers)\n\n# Sign up with email and password\nuser = client.sign_up(email=\"example@gmail.com\", password=\"*********\")\n\n# Sign in with email and password\nuser = client.sign_in_with_password(email=\"example@gmail.com\", password=\"*********\")\n\n# Sign in with magic link\nuser = client.sign_in_with_otp(email=\"example@gmail.com\")\n\n# Sign in with phone number\nuser = client.sign_in_with_otp(phone=\"+1234567890\")\n\n# Sign in with OAuth\nuser = client.sign_in_with_oauth(provider=\"google\")\n\n# Sign out\nclient.sign_out()\n\n# Get current user\nuser = client.get_user()\n\n# Update user profile\nuser = client.update_user({\"data\": {\"name\": \"John Doe\"}})\n```\n\n### Asynchronous Client\n\n```python\nfrom supabase_auth import AsyncGoTrueClient\n\nheaders = {\n    \"apiKey\": \"my-mega-awesome-api-key\",\n    # ... any other headers you might need.\n}\nclient: AsyncGoTrueClient = AsyncGoTrueClient(url=\"www.genericauthwebsite.com\", headers=headers)\n\nasync def main():\n    # Sign up with email and password\n    user = await client.sign_up(email=\"example@gmail.com\", password=\"*********\")\n\n    # Sign in with email and password\n    user = await client.sign_in_with_password(email=\"example@gmail.com\", password=\"*********\")\n\n    # Sign in with magic link\n    user = await client.sign_in_with_otp(email=\"example@gmail.com\")\n\n    # Sign in with phone number\n    user = await client.sign_in_with_otp(phone=\"+1234567890\")\n\n    # Sign in with OAuth\n    user = await client.sign_in_with_oauth(provider=\"google\")\n\n    # Sign out\n    await client.sign_out()\n\n    # Get current user\n    user = await client.get_user()\n\n    # Update user profile\n    user = await client.update_user({\"data\": {\"name\": \"John Doe\"}})\n\n# Run the async code\nimport asyncio\nasyncio.run(main())\n```\n\n### MFA Support\n\nThe library includes support for Multi-Factor Authentication:\n\n```python\n# List MFA factors\nfactors = client.mfa.list_factors()\n\n# Enroll a new MFA factor\nenrolled_factor = client.mfa.enroll({\"factor_type\": \"totp\"})\n\n# Challenge and verify MFA\nchallenge = client.mfa.challenge({\"factor_id\": \"factor_id\"})\nverified = client.mfa.verify({\"factor_id\": \"factor_id\", \"code\": \"123456\"})\n\n# Unenroll a factor\nclient.mfa.unenroll({\"factor_id\": \"factor_id\"})\n```\n\n## Contributions\n\nWe would be immensely grateful for any contributions to this project.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python Client Library for Supabase Auth",
    "version": "2.23.1",
    "project_urls": {
        "changelog": "https://github.com/supabase/supabase-py/tree/main/CHANGELOG.md",
        "documentation": "https://github.com/supabase/supabase-py/tree/main/src/auth",
        "homepage": "https://github.com/supabase/supabase-py/tree/main/src/auth",
        "repository": "https://github.com/supabase/supabase-py"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ed9e617eda9f3b20899a453f2b97781da79d3344ab2dfe657986bb54affb05a2",
                "md5": "fafe074b0d440005f732dab73719ab58",
                "sha256": "cc17ae08aae38c9ce685ffc63dc4241fda27fc109566f12cebbc742f09737218"
            },
            "downloads": -1,
            "filename": "supabase_auth-2.23.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fafe074b0d440005f732dab73719ab58",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 48356,
            "upload_time": "2025-11-03T14:30:12",
            "upload_time_iso_8601": "2025-11-03T14:30:12.680472Z",
            "url": "https://files.pythonhosted.org/packages/ed/9e/617eda9f3b20899a453f2b97781da79d3344ab2dfe657986bb54affb05a2/supabase_auth-2.23.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ae2223e93d551ebec1801b7424bdec3e8b3514d6335149b6ccf292f5d40e9a57",
                "md5": "43350ea76b2599ae450a26475f906086",
                "sha256": "25c08fdf87804863cf2a290d7ec46eb727065eac279f3b6179a1394973999c06"
            },
            "downloads": -1,
            "filename": "supabase_auth-2.23.1.tar.gz",
            "has_sig": false,
            "md5_digest": "43350ea76b2599ae450a26475f906086",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 39110,
            "upload_time": "2025-11-03T14:30:14",
            "upload_time_iso_8601": "2025-11-03T14:30:14.083731Z",
            "url": "https://files.pythonhosted.org/packages/ae/22/23e93d551ebec1801b7424bdec3e8b3514d6335149b6ccf292f5d40e9a57/supabase_auth-2.23.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-03 14:30:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "supabase",
    "github_project": "supabase-py",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "supabase-auth"
}
        
Elapsed time: 1.47487s