Stytch python client
Project description
Stytch Python API Client
Requirements:
Stytch python supports Python 3.4+
Installation:
pip install stytch
Usage:
from stytch import Client
# Initialize client
stytch_client = Client(
project_id="***YOUR PROJECT ID***",
secret="***YOUR PROJECT SECRET***",
environment="test",
)
# Create a user
resp = stytch_client.Users.create(email="person@app.com")
# Send magic link to user
stytch_client.MagicLink.send(
method_id=resp.user_id,
email=resp.email_id,
magic_link_url="https://my-app.com/login"
)
# Authenticate magic link
stytch_client.MagicLink.authenticate(token="*** EMAILED TOKEN ****")
Login Or Create User
stytch_client.MagicLink.login_or_create(
email="person@app.com",
login_magic_link_url="https://my-app.com/login",
signup_magic_link_url="https://my-app.com/signup"
)
Handling exceptions:
Handle Stytch exceptions with StytchErrors
from stytch.api.error import StytchError
try:
stytch_client.MagicLink.authenticate(token="token")
except StytchError as error:
# Handle stytch errors here
pass
except Exception as error:
# Handle error here
pass
Testing:
Unit tests are run via pytest tests/api
Integration tests accept a project_id + secret via command line
pytest tests/integration/test_integration.py --project_id="***YOUR PROJECT ID***" --secret="***YOUR SECRET KEY***" --email="***YOUR EMAIL***"
Documentation:
More information:
Visit https://stytch.com/ for more information
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stytch-1.3.5.tar.gz
(6.7 kB
view details)
File details
Details for the file stytch-1.3.5.tar.gz.
File metadata
- Download URL: stytch-1.3.5.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bb59da899e0d499f1213d751af0aa1c9e228ea07e16be17362eb778df20a494
|
|
| MD5 |
b5b7a487c122df0c5cba0b6dbf867ea5
|
|
| BLAKE2b-256 |
1a1cd8d92eaf35fb9ad5f73f4eeccf35d39a4d0e53b1504d87c9804c6845f4be
|