Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,128 @@ dmypy.json

# Cython debug symbols
cython_debug/

# Editors
.vscode/
.idea/

# Vagrant
.vagrant/

# Mac/OSX
.DS_Store

# Windows
Thumbs.db

# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json
5 changes: 2 additions & 3 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Contributor Covenant Code of Conduct

## Our Pledge
Expand Down Expand Up @@ -69,9 +68,9 @@ members of the project's leadership.
## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, what's the purpose of wrapping in < and >?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yup, it is that I use the VS Code extension for Markdown files and it has a rule for links without <>

Extension: https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
Rule: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md034---bare-url-used

The extension follows the specifications of https://commonmark.org

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks for the explanation.


[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
<https://www.contributor-covenant.org/faq>
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In the interest of fostering an open and welcoming environment, please review an

All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
[GitHub Help](https://help.github.com/articles/about-pull-requests) for more
information on using pull requests.

## Report an issue
Expand All @@ -27,6 +27,6 @@ When making pull requests to the repository, make sure to follow these guideline

- Before creating a pull request, file a GitHub Issue so that maintainers and the community can discuss the problem and potential solutions before you spend time on an implementation.
- In your PR's description, link to any related issues or pull requests to give reviewers the full context of your change.
- For commit messages, follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format.
- For commit messages, follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0) format.
- For example, if you update documentation for a specific extension, your commit message might be: `docs(extension-name) updated installation documentation`.
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
# Gotrue-py
This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js/). The current status is that there is not complete feature pairity when compared with the js-client, but this something we are working on.

This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current status is that there is not complete feature pairity when compared with the js-client, but this something we are working on.

## Installation

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

### Poetry

```bash
poetry add gotrue
```

### Pip

```bash
pip install gotrue
```

## 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.
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.
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.
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.

## Usage

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

```python
from gotrue import Client

Expand All @@ -41,23 +49,27 @@ client: Client = Client(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()
Expand All @@ -66,19 +78,22 @@ assert client.session() is not None
```

## Tests

At the moment we use a pre-defined supabase instance to test the functionality. This may change over time. You can run the tests like so:

```bash
SUPABASE_TEST_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYxMjYwOTMyMiwiZXhwIjoxOTI4MTg1MzIyfQ.XL9W5I_VRQ4iyQHVQmjG0BkwRfx6eVyYB3uAKcesukg" \
SUPABASE_TEST_URL="https://tfsatoopsijgjhrqplra.supabase.co" \
pytest -sx
```

## Contributions

We would be immensely grateful for any contributions to this project. In particular are the following items:

- [x] Figure out to use either Sessions to manage headers or allow passing in of headers
- [ ] Add documentation.
- [ ] Add more tests.
- [ ] Ensuring feature-parity with the js-client.
- [ ] Supporting 3rd party provider authentication.
- [ ] Implement a js port of setTimeout for the refresh session code.

125 changes: 0 additions & 125 deletions gotrue/.gitignore

This file was deleted.

Loading