Skip to main content

Passwordless.dev Python SDK

Project description

Passwordless Python SDK

Build Version Downloads

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:

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.8 installed. Install Poetry if not already installed.

Activate shell: poetry shell

Install dependencies: poetry install --with dev,test

Build: poetry build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

passwordless-1.0.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

passwordless-1.0.2-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file passwordless-1.0.2.tar.gz.

File metadata

  • Download URL: passwordless-1.0.2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for passwordless-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4bbf2e8b9e226daa127735cc127a7e30e5efc459d9f7770f00af44de85164885
MD5 814d9d79c92223a6d55abd3f502caa55
BLAKE2b-256 c665f46ac5fab130dd8ed65ba1a2626ff05ff9d89dda3c8fb96596c010ff23db

See more details on using hashes here.

File details

Details for the file passwordless-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: passwordless-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for passwordless-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 557aba0e2b7f8175179afb6f9c0180ada9a7fbeba3d8db6b72c6950b671c02b6
MD5 70b5d3ce02f8e171ce9b14766d21dc9a
BLAKE2b-256 18509e0c26330c14af6240a0de20411864cd31c6600d188b10403ea2d223710e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page