Name | stytch JSON |
Version |
9.4.0
JSON |
| download |
home_page | None |
Summary | Stytch python client |
upload_time | 2024-05-10 19:42:33 |
maintainer | None |
docs_url | None |
author | Stytch |
requires_python | >=3.8 |
license | MIT |
keywords |
stytch
user
authentication
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Stytch Python Library
The Stytch Python library makes it easy to use the Stytch user infrastructure API in Python applications.
It pairs well with the Stytch [Web SDK](https://www.npmjs.com/package/@stytch/vanilla-js) or your own custom authentication flow.
## Requirements
The Stytch Python library supports Python 3.8+
## Installation
```
pip install stytch
```
## Usage
You can find your API credentials in the [Stytch Dashboard](https://stytch.com/dashboard/api-keys).
This client library supports all Stytch's live products:
- [x] [Email Magic Links](https://stytch.com/docs/api/send-by-email)
- [x] [Embeddable Magic Links](https://stytch.com/docs/guides/magic-links/embeddable-magic-links/api)
- [x] [OAuth logins](https://stytch.com/docs/guides/oauth/idp-overview)
- [x] [SMS passcodes](https://stytch.com/docs/api/send-otp-by-sms)
- [x] [WhatsApp passcodes](https://stytch.com/docs/api/whatsapp-send)
- [x] [Email passcodes](https://stytch.com/docs/api/send-otp-by-email)
- [x] [Session Management](https://stytch.com/docs/guides/sessions/using-sessions)
- [x] [WebAuthn](https://stytch.com/docs/guides/webauthn/api)
- [x] [Time-based one-time passcodes (TOTPs)](https://stytch.com/docs/guides/totp/api)
- [x] [Crypto wallets](https://stytch.com/docs/guides/web3/api)
- [x] [Passwords](https://stytch.com/docs/guides/passwords/api)
### Example usage
Create an API client:
```python
import stytch
client = stytch.Client(
project_id="project-live-c60c0abe-c25a-4472-a9ed-320c6667d317",
secret="secret-live-80JASucyk7z_G8Z-7dVwZVGXL5NT_qGAQ2I=",
)
```
Send a magic link by email:
```python
login_or_create_resp = client.magic_links.email.login_or_create(
email="sandbox@stytch.com",
login_magic_link_url="https://example.com/authenticate",
signup_magic_link_url="https://example.com/authenticate",
)
# Responses are fully-typed `pydantic` objects
print(login_or_create_resp)
```
Authenticate the token from the magic link:
```python
auth_resp = client.magic_links.authenticate(
token="DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94=",
)
print(auth_resp)
```
## Async support
Every endpoint supports an `async` version which you can use by appending `_async` to the method name. You can use the
same `Client` object for `sync` and `async` methods. The above example of sending and authenticating an magic link can
be rewritten as:
```python
login_or_create_resp = await client.magic_links.email.login_or_create_async(
email="sandbox@stytch.com",
login_magic_link_url="https://example.com/authenticate",
signup_magic_link_url="https://example.com/authenticate",
)
print(login_or_create_resp)
auth_resp = await client.magic_links.authenticate(
token="DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94=",
)
print(resp)
```
## Handling Errors
Structured errors from the Stytch API will raise `StytchError` exceptions. You can view the details of the error through
the `.details` property of the `StytchError` exception.
```python
from stytch.core.response_base import StytchError
try:
auth_resp = await client.magic_links.authenticate_async(token="token")
except StytchError as error:
# Handle Stytch errors here
if error.details.error_type == "invalid_token":
print("Whoops! Try again?")
except Exception as error:
# Handle other errors here
pass
```
Learn more about errors in the [docs](https://stytch.com/docs/api/errors).
## Documentation
See example requests and responses for all the endpoints in the [Stytch API Reference](https://stytch.com/docs/api).
Follow one of the [integration guides](https://stytch.com/docs/home#guides) or start with one of our [example apps](https://stytch.com/docs/home#example-apps).
## Support
If you've found a bug, [open an issue](https://github.com/stytchauth/stytch-python/issues/new)!
If you have questions or want help troubleshooting, join us in [Slack](https://stytch.slack.com/join/shared_invite/zt-2f0fi1ruu-ub~HGouWRmPARM1MTwPESA) or email support@stytch.com.
If you've found a security vulnerability, please follow our [responsible disclosure instructions](https://stytch.com/docs/resources/security-and-trust/security#:~:text=Responsible%20disclosure%20program).
## Development
See [DEVELOPMENT.md](DEVELOPMENT.md)
## Code of Conduct
Everyone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
Raw data
{
"_id": null,
"home_page": null,
"name": "stytch",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "stytch, user, authentication",
"author": "Stytch",
"author_email": "hello@stytch.com",
"download_url": "https://files.pythonhosted.org/packages/3a/b6/c128608e3f551e431498911141cb0278cc452ab606a76b5ffbb262417e56/stytch-9.4.0.tar.gz",
"platform": null,
"description": "# Stytch Python Library\n\nThe Stytch Python library makes it easy to use the Stytch user infrastructure API in Python applications.\n\nIt pairs well with the Stytch [Web SDK](https://www.npmjs.com/package/@stytch/vanilla-js) or your own custom authentication flow.\n\n## Requirements\n\nThe Stytch Python library supports Python 3.8+\n\n## Installation\n\n```\npip install stytch\n```\n\n## Usage\n\nYou can find your API credentials in the [Stytch Dashboard](https://stytch.com/dashboard/api-keys).\n\nThis client library supports all Stytch's live products:\n\n- [x] [Email Magic Links](https://stytch.com/docs/api/send-by-email)\n- [x] [Embeddable Magic Links](https://stytch.com/docs/guides/magic-links/embeddable-magic-links/api)\n- [x] [OAuth logins](https://stytch.com/docs/guides/oauth/idp-overview)\n- [x] [SMS passcodes](https://stytch.com/docs/api/send-otp-by-sms)\n- [x] [WhatsApp passcodes](https://stytch.com/docs/api/whatsapp-send)\n- [x] [Email passcodes](https://stytch.com/docs/api/send-otp-by-email)\n- [x] [Session Management](https://stytch.com/docs/guides/sessions/using-sessions)\n- [x] [WebAuthn](https://stytch.com/docs/guides/webauthn/api)\n- [x] [Time-based one-time passcodes (TOTPs)](https://stytch.com/docs/guides/totp/api)\n- [x] [Crypto wallets](https://stytch.com/docs/guides/web3/api)\n- [x] [Passwords](https://stytch.com/docs/guides/passwords/api)\n\n### Example usage\n\nCreate an API client:\n\n```python\nimport stytch\n\nclient = stytch.Client(\n project_id=\"project-live-c60c0abe-c25a-4472-a9ed-320c6667d317\",\n secret=\"secret-live-80JASucyk7z_G8Z-7dVwZVGXL5NT_qGAQ2I=\",\n)\n```\n\nSend a magic link by email:\n\n```python\nlogin_or_create_resp = client.magic_links.email.login_or_create(\n email=\"sandbox@stytch.com\",\n login_magic_link_url=\"https://example.com/authenticate\",\n signup_magic_link_url=\"https://example.com/authenticate\",\n)\n# Responses are fully-typed `pydantic` objects\nprint(login_or_create_resp)\n```\n\nAuthenticate the token from the magic link:\n\n```python\nauth_resp = client.magic_links.authenticate(\n token=\"DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94=\",\n)\nprint(auth_resp)\n```\n\n## Async support\n\nEvery endpoint supports an `async` version which you can use by appending `_async` to the method name. You can use the\nsame `Client` object for `sync` and `async` methods. The above example of sending and authenticating an magic link can\nbe rewritten as:\n\n```python\nlogin_or_create_resp = await client.magic_links.email.login_or_create_async(\n email=\"sandbox@stytch.com\",\n login_magic_link_url=\"https://example.com/authenticate\",\n signup_magic_link_url=\"https://example.com/authenticate\",\n)\nprint(login_or_create_resp)\n\nauth_resp = await client.magic_links.authenticate(\n token=\"DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94=\",\n)\nprint(resp)\n```\n\n## Handling Errors\n\nStructured errors from the Stytch API will raise `StytchError` exceptions. You can view the details of the error through\nthe `.details` property of the `StytchError` exception.\n\n```python\nfrom stytch.core.response_base import StytchError\n\ntry:\n auth_resp = await client.magic_links.authenticate_async(token=\"token\")\nexcept StytchError as error:\n # Handle Stytch errors here\n if error.details.error_type == \"invalid_token\":\n print(\"Whoops! Try again?\")\nexcept Exception as error:\n # Handle other errors here\n pass\n```\n\nLearn more about errors in the [docs](https://stytch.com/docs/api/errors).\n\n## Documentation\n\nSee example requests and responses for all the endpoints in the [Stytch API Reference](https://stytch.com/docs/api).\n\nFollow one of the [integration guides](https://stytch.com/docs/home#guides) or start with one of our [example apps](https://stytch.com/docs/home#example-apps).\n\n## Support\n\nIf you've found a bug, [open an issue](https://github.com/stytchauth/stytch-python/issues/new)!\n\nIf you have questions or want help troubleshooting, join us in [Slack](https://stytch.slack.com/join/shared_invite/zt-2f0fi1ruu-ub~HGouWRmPARM1MTwPESA) or email support@stytch.com.\n\nIf you've found a security vulnerability, please follow our [responsible disclosure instructions](https://stytch.com/docs/resources/security-and-trust/security#:~:text=Responsible%20disclosure%20program).\n\n## Development\n\nSee [DEVELOPMENT.md](DEVELOPMENT.md)\n\n## Code of Conduct\n\nEveryone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Stytch python client",
"version": "9.4.0",
"project_urls": {
"Download": "https://github.com/stytchauth/stytch-python"
},
"split_keywords": [
"stytch",
" user",
" authentication"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3ab6c128608e3f551e431498911141cb0278cc452ab606a76b5ffbb262417e56",
"md5": "ea6256c4968890e8409bb674a35da78d",
"sha256": "555f889d5d6c52ed7081c24f031183456939159301e6eeb700a616c089ae686a"
},
"downloads": -1,
"filename": "stytch-9.4.0.tar.gz",
"has_sig": false,
"md5_digest": "ea6256c4968890e8409bb674a35da78d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 111981,
"upload_time": "2024-05-10T19:42:33",
"upload_time_iso_8601": "2024-05-10T19:42:33.231858Z",
"url": "https://files.pythonhosted.org/packages/3a/b6/c128608e3f551e431498911141cb0278cc452ab606a76b5ffbb262417e56/stytch-9.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-10 19:42:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "stytchauth",
"github_project": "stytch-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "stytch"
}