passwordless


Namepasswordless JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://bitwarden.com/products/passwordless
SummaryPasswordless.dev Python SDK
upload_time2024-04-25 10:38:22
maintainerMaciej Zieniuk
docs_urlNone
authorBitwarden
requires_python>=3.8
licenseApache-2.0
keywords passwordless bitwarden
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.8 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.8",
    "maintainer_email": "zieniuk.maciej@gmail.com",
    "keywords": "passwordless, bitwarden",
    "author": "Bitwarden",
    "author_email": "hello@bitwarden.com",
    "download_url": "https://files.pythonhosted.org/packages/44/58/590ea6e613cb85020fb7aa8bff1ef98780b1c37df9ab848cb81424f1efe4/passwordless-1.0.1.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.8 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": "1.0.1",
    "project_urls": {
        "Documentation": "https://docs.passwordless.dev/guide",
        "Homepage": "https://bitwarden.com/products/passwordless"
    },
    "split_keywords": [
        "passwordless",
        " bitwarden"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "60fff4df06fd3b93ab4d977e4b1291670626c5e396c481c0e99804bfec12c1e5",
                "md5": "4b0187935cbf94671b43835b81bc1e79",
                "sha256": "0b2261491f3b0382ca81e0796d2438795337059b00ea8c7dbc15e78dc8adc7b5"
            },
            "downloads": -1,
            "filename": "passwordless-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4b0187935cbf94671b43835b81bc1e79",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13379,
            "upload_time": "2024-04-25T10:38:21",
            "upload_time_iso_8601": "2024-04-25T10:38:21.436026Z",
            "url": "https://files.pythonhosted.org/packages/60/ff/f4df06fd3b93ab4d977e4b1291670626c5e396c481c0e99804bfec12c1e5/passwordless-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4458590ea6e613cb85020fb7aa8bff1ef98780b1c37df9ab848cb81424f1efe4",
                "md5": "033ebf5b9e0f0a8b5e0586e67f2195c5",
                "sha256": "a17f4fd7b8f8a32981f9abf8870dd19130e4d1f9c82337e87f624a894d1c9efa"
            },
            "downloads": -1,
            "filename": "passwordless-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "033ebf5b9e0f0a8b5e0586e67f2195c5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12656,
            "upload_time": "2024-04-25T10:38:22",
            "upload_time_iso_8601": "2024-04-25T10:38:22.407544Z",
            "url": "https://files.pythonhosted.org/packages/44/58/590ea6e613cb85020fb7aa8bff1ef98780b1c37df9ab848cb81424f1efe4/passwordless-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 10:38:22",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "passwordless"
}
        
Elapsed time: 0.23925s