https://github.com/bitwarden/passwordless-python
Bitwarden Passwordless.dev Python SDK.
https://github.com/bitwarden/passwordless-python
bitwarden python
Last synced: about 2 months ago
JSON representation
Bitwarden Passwordless.dev Python SDK.
- Host: GitHub
- URL: https://github.com/bitwarden/passwordless-python
- Owner: bitwarden
- License: apache-2.0
- Created: 2023-09-15T12:51:31.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-16T23:07:59.000Z (about 2 months ago)
- Last Synced: 2025-08-17T01:05:09.904Z (about 2 months ago)
- Topics: bitwarden, python
- Language: Python
- Homepage: https://bitwarden.com/
- Size: 449 KB
- Stars: 23
- Watchers: 15
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Passwordless Python SDK
[](https://github.com/bitwarden/passwordless-python/actions)
[](https://pypi.org/project/passwordless/)
[](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: PasswordlessClientdef __init__(self):
options = PasswordlessOptions("your_api_secret")self.client = PasswordlessClientBuilder(options).build()
```
### Register a passkey
```python
import uuid
from passwordless import PasswordlessClient, RegisterToken, RegisteredTokenclass PasswordlessPythonSdkExample:
client: PasswordlessClientdef 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, VerifiedUserclass PasswordlessPythonSdkExample:
client: PasswordlessClientdef 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/