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***"
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.2.0.tar.gz
(5.9 kB
view hashes)
Built Distribution
stytch-1.2.0-py3-none-any.whl
(7.6 kB
view hashes)