Skip to content

Repository files navigation

Passwordless Python SDK

BuildVersionDownloads

The official Bitwarden Passwordless.dev Python library, for Python 3+.

Installation

Install with python -m pip install passwordless.

Dependencies

Getting Started

Follow the Get started guide.

Create PasswordlessClient instance:

frompasswordlessimport (
PasswordlessClient,
PasswordlessClientBuilder,
PasswordlessOptions,
)
classPasswordlessPythonSdkExample:
client: PasswordlessClientdef__init__(self):
options=PasswordlessOptions("your_api_secret")
self.client=PasswordlessClientBuilder(options).build()

Register a passkey

importuuidfrompasswordlessimportPasswordlessClient, RegisterToken, RegisteredTokenclassPasswordlessPythonSdkExample:
client: PasswordlessClientdefget_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 Apiregister_token=RegisterToken(
user_id=user_id, # your user idusername=alias, # e.g. user email, is shown in browser uialiases=[alias] # Optional: Link this userid to an alias (e.g. email)
)
response: RegisteredToken=self.client.register_token(register_token)
# return this tokenreturnresponse.token

Verify user

frompasswordlessimportPasswordlessClient, VerifySignIn, VerifiedUserclassPasswordlessPythonSdkExample:
client: PasswordlessClientdefverify_sign_in_token(self, token: str) ->VerifiedUser:
verify_sign_in=VerifySignIn(token)
# Sign the user in, set a cookie, etc,returnself.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 sessionrequests 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

About

Bitwarden Passwordless.dev Python SDK.

Topics

Resources

Contributing

Security policy

Stars

31 stars

Watchers

16 watching

Forks

Releases

Used by

Contributors

Languages