Passwordless Python SDK
The official Bitwarden Passwordless.dev Python library, for Python 3+.
Installation
Install with python -m pip install passwordless.
Dependencies
- Requests for HTTP API
- marshmallow for JSON (de)serialization
Getting Started
Follow the Get started guide.
Create PasswordlessClient instance:
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
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
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 instance.
Examples
See Passwordless Python Example for Flash Web application.
Documentation
For a comprehensive list of examples, check out the API documentation.
Contributing
This library is compatible with Python 3 and requires minimum Python 3.9 installed. Install Poetry if not already installed.
Activate shell: poetry shell
Install dependencies: poetry install --with dev,test
Build: poetry build
Metadata
Release files for passwordless 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| passwordless-2.0.0.tar.gz | 12.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| passwordless-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.0 kB
Release files / passwordless-2.0.0.tar.gz
| Download URL | passwordless-2.0.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71b7ceca5a1af1dced4d983a3fea3e1c11d9b5b8d0696e6571ed92c2b4c49247
|
|
BLAKE2b-256 checksum How to use checksums |
7303ac2e6e151760a82e00a8558db5d934af27468c65e95ae47a32a00bf08b69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-1014-azure
|
Release files / passwordless-2.0.0-py3-none-any.whl
| Download URL | passwordless-2.0.0-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3fcc0e4f8b667c883f331f9b1690c8812873f258de931a0a2949c0b5b95565a
|
|
BLAKE2b-256 checksum How to use checksums |
92df842b87dfaebc8e04ded75126378364d27ca55a98066012aee414e54f72f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-1014-azure
|