Skip to main content

gotrue-py

License: MIT CI Python Version Codecov Last commit GitHub commit activity Github Stars Github Forks Github Watchers GitHub contributors

This is a Python port of the supabase js gotrue client. 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.

Installation

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

Poetry

poetry add gotrue

Pip

pip install gotrue

Differences to the JS client

It should be noted there are differences to the JS client. 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. In most cases we match the methods and attributes of the JS client 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, 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.

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 gotrue library for Python parses the date-time string into datetime Python objects. The JS client keeps the date-time as strings.

Usage (outdated)

Important: This section is outdated, you can be guided by the JS client documentation 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.

from gotrue 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:

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

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

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.

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

We can refesh a users session.

# 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. In particular are the following items:

Metadata

Release files for supabase_auth 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for supabase_auth 0.1.0
File Size Uploaded Provenance Actions
supabase_auth-0.1.0.tar.gz 36.3 kB Without provenance Details for supabase_auth-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for supabase_auth 0.1.0
File Interpreter ABI Platform Actions
supabase_auth-0.1.0-py3-none-any.whl Python 3 none any Details for supabase_auth-0.1.0-py3-none-any.whl

Total release size: 79.4 kB

Release files / supabase_auth-0.1.0.tar.gz

Download URL supabase_auth-0.1.0.tar.gz
Size 36.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ec3db15a15ba009dfc3970883afe376d30ec823cc28e056d0ff2c43b97893e87
BLAKE2b-256 checksum
How to use checksums
5540038f82d0d2619fb203517f9d0c7b3c0419e6a9e4d9776c3474b5409103dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.3 Darwin/22.2.0

Release files / supabase_auth-0.1.0-py3-none-any.whl

Download URL supabase_auth-0.1.0-py3-none-any.whl
Size 43.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbd79134433d81f100af120cfbbfa13960f5ccea8fd5e1d130a03a405d2dcade
BLAKE2b-256 checksum
How to use checksums
5c68df3211196297c31440dcd4fdaed78b1d7d258161a98ebdf96c7ee2313ae2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.3 Darwin/22.2.0

Security for supabase_auth 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page