supabase-auth


Namesupabase-auth JSON
Version 2.11.0 PyPI version JSON
download
home_pagehttps://github.com/supabase/auth-py
SummaryPython Client Library for Supabase Auth
upload_time2024-11-24 15:49:38
maintainerNone
docs_urlNone
authorJoel Lee
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Auth-py

[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?label=license)](https://opensource.org/licenses/MIT)
[![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)
[![Codecov](https://codecov.io/gh/supabase-community/gotrue-py/branch/main/graph/badge.svg)](https://codecov.io/gh/supabase-community/gotrue-py)
[![Last commit](https://img.shields.io/github/last-commit/supabase-community/gotrue-py.svg?style=flat)](https://github.com/supabase-community/gotrue-py/commits)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/supabase-community/gotrue-py)](https://github.com/supabase-community/gotrue-py/commits)
[![Github Stars](https://img.shields.io/github/stars/supabase-community/gotrue-py?style=flat&logo=github)](https://github.com/supabase-community/gotrue-py/stargazers)
[![Github Forks](https://img.shields.io/github/forks/supabase-community/gotrue-py?style=flat&logo=github)](https://github.com/supabase-community/gotrue-py/network/members)
[![Github Watchers](https://img.shields.io/github/watchers/supabase-community/gotrue-py?style=flat&logo=github)](https://github.com/supabase-community/gotrue-py)
[![GitHub contributors](https://img.shields.io/github/contributors/supabase-community/gotrue-py)](https://github.com/supabase-community/gotrue-py/graphs/contributors)

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

We are still working on making the `supabase_auth` python library more user-friendly. For now here are some sparse notes on how to install the module.

### Poetry

```bash
poetry add supabase_auth
```

### Pip

```bash
pip install supabase_auth
```

## 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 (outdated)

**Important:** This section is outdated, you can be guided by the [JS client documentation](https://supabase.github.io/gotrue-js) because this Python client has a lot of parity with the JS client.

To instantiate the client, you'll need the URL and any request headers at a minimum.

```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)
```

To send a magic email link to the user, just provide the email kwarg to the `sign_in` method:

```python
user: Dict[str, Any] = client.sign_up(email="example@gmail.com")
```

To login with email and password, provide both to the `sign_in` method:

```python
user: Dict[str, Any] = client.sign_up(email="example@gmail.com", password="*********")
```

To sign out of the logged in user, call the `sign_out` method. We can then assert that the session and user are null values.

```python
client.sign_out()
assert client.user() is None
assert client.session() is None
```

We can refesh a users session.

```python
# The user should already be signed in at this stage.
user = client.refresh_session()
assert client.user() is not None
assert client.session() is not None
```

## Contributions

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


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/supabase/auth-py",
    "name": "supabase-auth",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Joel Lee",
    "author_email": "joel@joellee.org",
    "download_url": "https://files.pythonhosted.org/packages/7a/71/c77a72787e631b637d46f0df6cd3b02195c8ec1a86293e80d81178d7e3ca/supabase_auth-2.11.0.tar.gz",
    "platform": null,
    "description": "# Auth-py\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?label=license)](https://opensource.org/licenses/MIT)\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[![Codecov](https://codecov.io/gh/supabase-community/gotrue-py/branch/main/graph/badge.svg)](https://codecov.io/gh/supabase-community/gotrue-py)\n[![Last commit](https://img.shields.io/github/last-commit/supabase-community/gotrue-py.svg?style=flat)](https://github.com/supabase-community/gotrue-py/commits)\n[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/supabase-community/gotrue-py)](https://github.com/supabase-community/gotrue-py/commits)\n[![Github Stars](https://img.shields.io/github/stars/supabase-community/gotrue-py?style=flat&logo=github)](https://github.com/supabase-community/gotrue-py/stargazers)\n[![Github Forks](https://img.shields.io/github/forks/supabase-community/gotrue-py?style=flat&logo=github)](https://github.com/supabase-community/gotrue-py/network/members)\n[![Github Watchers](https://img.shields.io/github/watchers/supabase-community/gotrue-py?style=flat&logo=github)](https://github.com/supabase-community/gotrue-py)\n[![GitHub contributors](https://img.shields.io/github/contributors/supabase-community/gotrue-py)](https://github.com/supabase-community/gotrue-py/graphs/contributors)\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\nWe are still working on making the `supabase_auth` python library more user-friendly. For now here are some sparse notes on how to install the module.\n\n### Poetry\n\n```bash\npoetry add supabase_auth\n```\n\n### Pip\n\n```bash\npip install supabase_auth\n```\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 (outdated)\n\n**Important:** This section is outdated, you can be guided by the [JS client documentation](https://supabase.github.io/gotrue-js) because this Python client has a lot of parity with the JS client.\n\nTo instantiate the client, you'll need the URL and any request headers at a minimum.\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\nTo send a magic email link to the user, just provide the email kwarg to the `sign_in` method:\n\n```python\nuser: Dict[str, Any] = client.sign_up(email=\"example@gmail.com\")\n```\n\nTo login with email and password, provide both to the `sign_in` method:\n\n```python\nuser: Dict[str, Any] = client.sign_up(email=\"example@gmail.com\", password=\"*********\")\n```\n\nTo sign out of the logged in user, call the `sign_out` method. We can then assert that the session and user are null values.\n\n```python\nclient.sign_out()\nassert client.user() is None\nassert client.session() is None\n```\n\nWe can refesh a users session.\n\n```python\n# The user should already be signed in at this stage.\nuser = client.refresh_session()\nassert client.user() is not None\nassert client.session() is not None\n```\n\n## Contributions\n\nWe would be immensely grateful for any contributions to this project. \n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python Client Library for Supabase Auth",
    "version": "2.11.0",
    "project_urls": {
        "Documentation": "https://github.com/supabase/auth-py",
        "Homepage": "https://github.com/supabase/auth-py",
        "Repository": "https://github.com/supabase/auth-py"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c2f85046dc94887a51b821449f5b090ef60a636fbf5fda5bf2f27a79f4eef523",
                "md5": "c59ec74add8edbc89af64590103d4d50",
                "sha256": "0a33c31037fe3ab39b0bbed10ea73cd0c7b599480f7a878685a35db385a1ed42"
            },
            "downloads": -1,
            "filename": "supabase_auth-2.11.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c59ec74add8edbc89af64590103d4d50",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 49329,
            "upload_time": "2024-11-24T15:49:36",
            "upload_time_iso_8601": "2024-11-24T15:49:36.284705Z",
            "url": "https://files.pythonhosted.org/packages/c2/f8/5046dc94887a51b821449f5b090ef60a636fbf5fda5bf2f27a79f4eef523/supabase_auth-2.11.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a71c77a72787e631b637d46f0df6cd3b02195c8ec1a86293e80d81178d7e3ca",
                "md5": "a5c162008062377e6b23a3522da40bf8",
                "sha256": "da634bee328ec07a33b0c2348f0e7b99e0fe546210861ac2ff7a1eafe06bc301"
            },
            "downloads": -1,
            "filename": "supabase_auth-2.11.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a5c162008062377e6b23a3522da40bf8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 41819,
            "upload_time": "2024-11-24T15:49:38",
            "upload_time_iso_8601": "2024-11-24T15:49:38.826067Z",
            "url": "https://files.pythonhosted.org/packages/7a/71/c77a72787e631b637d46f0df6cd3b02195c8ec1a86293e80d81178d7e3ca/supabase_auth-2.11.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-24 15:49:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "supabase",
    "github_project": "auth-py",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "supabase-auth"
}
        
Elapsed time: 1.64646s