# Passwordless Python SDK
[![Build](https://img.shields.io/github/actions/workflow/status/bitwarden/passwordless-python/ci.yml?branch=main)](https://github.com/bitwarden/passwordless-python/actions)
[![Version](https://img.shields.io/pypi/v/Passwordless.svg)](https://pypi.org/project/passwordless/)
[![Downloads](https://img.shields.io/pypi/dm/Passwordless.svg)](https://pypi.org/project/passwordless/)
The official [Bitwarden Passwordless.dev](https://passwordless.dev/) Python library, for Python 3+.
## Installation
Install with `python -m pip install passwordless`.
### Dependencies
- [Requests][requests] for HTTP API
- [marshmallow][marshmallow] for JSON (de)serialization
## Getting Started
Follow the [Get started guide][api-docs].
### Create `PasswordlessClient` instance:
```python
from passwordless import (
PasswordlessClient,
PasswordlessClientBuilder,
PasswordlessOptions,
)
class PasswordlessPythonSdkExample:
client: PasswordlessClient
def __init__(self):
options = PasswordlessOptions("your_api_secret")
self.client = PasswordlessClientBuilder(options).build()
```
### Register a passkey
```python
import uuid
from passwordless import PasswordlessClient, RegisterToken, RegisteredToken
class PasswordlessPythonSdkExample:
client: PasswordlessClient
def get_register_token(self, alias: str) -> str:
# Get existing userid from session or create a new user.
user_id = str(uuid.uuid4())
# Options to give the Api
register_token = RegisterToken(
user_id=user_id, # your user id
username=alias, # e.g. user email, is shown in browser ui
aliases=[alias] # Optional: Link this userid to an alias (e.g. email)
)
response: RegisteredToken = self.client.register_token(register_token)
# return this token
return response.token
```
### Verify user
```python
from passwordless import PasswordlessClient, VerifySignIn, VerifiedUser
class PasswordlessPythonSdkExample:
client: PasswordlessClient
def verify_sign_in_token(self, token: str) -> VerifiedUser:
verify_sign_in = VerifySignIn(token)
# Sign the user in, set a cookie, etc,
return self.client.sign_in(verify_sign_in)
```
### Customization
Customize `PasswordlessOptions` by providing `api_secret` with your Application's Api Secret.
You can also change the `api_url` if you prefer to self-host.
Customize `PasswordlessClientBuilder` by providing `session` [requests Session][requests] instance.
### Examples
See [Passwordless Python Example](examples/flask) for Flash Web application.
## Documentation
For a comprehensive list of examples, check out the [API documentation][api-docs].
## Contributing
This library is compatible with Python 3 and requires minimum Python 3.9 installed.
Install [Poetry][poetry] if not already installed.
Activate shell: `poetry shell`
Install dependencies: `poetry install --with dev,test`
Build: `poetry build`
[api-docs]:https://docs.passwordless.dev/guide/get-started.html
[poetry]:https://python-poetry.org/docs/#installation
[requests]:https://requests.readthedocs.io/en/latest/
[marshmallow]:https://marshmallow.readthedocs.io/en/stable/
Raw data
{
"_id": null,
"home_page": "https://bitwarden.com/products/passwordless",
"name": "passwordless",
"maintainer": "Maciej Zieniuk",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "zieniuk.maciej@gmail.com",
"keywords": "passwordless, bitwarden",
"author": "Bitwarden",
"author_email": "hello@bitwarden.com",
"download_url": "https://files.pythonhosted.org/packages/73/03/ac2e6e151760a82e00a8558db5d934af27468c65e95ae47a32a00bf08b69/passwordless-2.0.0.tar.gz",
"platform": null,
"description": "# Passwordless Python SDK\n\n[![Build](https://img.shields.io/github/actions/workflow/status/bitwarden/passwordless-python/ci.yml?branch=main)](https://github.com/bitwarden/passwordless-python/actions)\n[![Version](https://img.shields.io/pypi/v/Passwordless.svg)](https://pypi.org/project/passwordless/)\n[![Downloads](https://img.shields.io/pypi/dm/Passwordless.svg)](https://pypi.org/project/passwordless/)\n\nThe official [Bitwarden Passwordless.dev](https://passwordless.dev/) Python library, for Python 3+.\n\n## Installation\n\nInstall with `python -m pip install passwordless`.\n\n### Dependencies\n\n- [Requests][requests] for HTTP API\n- [marshmallow][marshmallow] for JSON (de)serialization\n\n## Getting Started\n\nFollow the [Get started guide][api-docs].\n\n### Create `PasswordlessClient` instance:\n\n```python\nfrom passwordless import (\n PasswordlessClient,\n PasswordlessClientBuilder,\n PasswordlessOptions,\n)\n\n\nclass PasswordlessPythonSdkExample:\n client: PasswordlessClient\n\n def __init__(self):\n options = PasswordlessOptions(\"your_api_secret\")\n\n self.client = PasswordlessClientBuilder(options).build()\n\n```\n\n### Register a passkey\n\n```python\nimport uuid\nfrom passwordless import PasswordlessClient, RegisterToken, RegisteredToken\n\n\nclass PasswordlessPythonSdkExample:\n client: PasswordlessClient\n\n def get_register_token(self, alias: str) -> str:\n # Get existing userid from session or create a new user.\n user_id = str(uuid.uuid4())\n\n # Options to give the Api\n register_token = RegisterToken(\n user_id=user_id, # your user id\n username=alias, # e.g. user email, is shown in browser ui\n aliases=[alias] # Optional: Link this userid to an alias (e.g. email)\n )\n\n response: RegisteredToken = self.client.register_token(register_token)\n\n # return this token\n return response.token\n```\n\n### Verify user\n\n```python\nfrom passwordless import PasswordlessClient, VerifySignIn, VerifiedUser\n\n\nclass PasswordlessPythonSdkExample:\n client: PasswordlessClient\n\n def verify_sign_in_token(self, token: str) -> VerifiedUser:\n verify_sign_in = VerifySignIn(token)\n\n # Sign the user in, set a cookie, etc,\n return self.client.sign_in(verify_sign_in)\n```\n\n### Customization\n\nCustomize `PasswordlessOptions` by providing `api_secret` with your Application's Api Secret.\nYou can also change the `api_url` if you prefer to self-host.\n\nCustomize `PasswordlessClientBuilder` by providing `session` [requests Session][requests] instance.\n\n### Examples\n\nSee [Passwordless Python Example](examples/flask) for Flash Web application.\n\n## Documentation\n\nFor a comprehensive list of examples, check out the [API documentation][api-docs].\n\n## Contributing\n\nThis library is compatible with Python 3 and requires minimum Python 3.9 installed.\nInstall [Poetry][poetry] if not already installed.\n\nActivate shell: `poetry shell`\n\nInstall dependencies: `poetry install --with dev,test`\n\nBuild: `poetry build`\n\n[api-docs]:https://docs.passwordless.dev/guide/get-started.html\n\n[poetry]:https://python-poetry.org/docs/#installation\n\n[requests]:https://requests.readthedocs.io/en/latest/\n\n[marshmallow]:https://marshmallow.readthedocs.io/en/stable/\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Passwordless.dev Python SDK",
"version": "2.0.0",
"project_urls": {
"Documentation": "https://docs.passwordless.dev/guide",
"Homepage": "https://bitwarden.com/products/passwordless"
},
"split_keywords": [
"passwordless",
" bitwarden"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "92df842b87dfaebc8e04ded75126378364d27ca55a98066012aee414e54f72f0",
"md5": "5bd7b699993c2e2286fd5e329d71b1a2",
"sha256": "b3fcc0e4f8b667c883f331f9b1690c8812873f258de931a0a2949c0b5b95565a"
},
"downloads": -1,
"filename": "passwordless-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5bd7b699993c2e2286fd5e329d71b1a2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 13370,
"upload_time": "2024-09-24T14:34:03",
"upload_time_iso_8601": "2024-09-24T14:34:03.811791Z",
"url": "https://files.pythonhosted.org/packages/92/df/842b87dfaebc8e04ded75126378364d27ca55a98066012aee414e54f72f0/passwordless-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7303ac2e6e151760a82e00a8558db5d934af27468c65e95ae47a32a00bf08b69",
"md5": "ee07098c168a81fd97330d3a74d06fae",
"sha256": "71b7ceca5a1af1dced4d983a3fea3e1c11d9b5b8d0696e6571ed92c2b4c49247"
},
"downloads": -1,
"filename": "passwordless-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "ee07098c168a81fd97330d3a74d06fae",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 12679,
"upload_time": "2024-09-24T14:34:04",
"upload_time_iso_8601": "2024-09-24T14:34:04.911273Z",
"url": "https://files.pythonhosted.org/packages/73/03/ac2e6e151760a82e00a8558db5d934af27468c65e95ae47a32a00bf08b69/passwordless-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-24 14:34:04",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "passwordless"
}