Skip to main content

User Token

User token generation in Python for the Tanker SDK.

https://travis-ci.org/TankerHQ/user-token-python.svg?branch=master https://img.shields.io/pypi/v/tankersdk-user-token.svg

Installation

With pip:

$ pip install tankersdk-user-token

Usage

import tankersdk.usertoken

def retrieve_user_token(user_id):
    """ Fetch a previously stored token """
    ...


 def store_user_token(user_id, token):
    """ Store a previously generated token """
    ...


 def check_auth(user_id):
    """ Check the user is authenticated """
    ...


def serve_user_token(user_id):
    """ Called during sign/up sign in of your users.

    Send a user token, generated if necessary, but only to
    authenticated users
    """
    authorized = check_auth(user_id)
    if not authorized:
        raise UnAuthorizedError()

    token = retrieve_user_token(user_id)

    if not token:
      token = tankersdk.usertoken.generate_user_token(trustchain_id, trustchain_private_key, user_id)
      store_user_token(user_id, token)

    return token

Going further

Read more about user tokens in the Tanker guide.

Check the examples folder for usage examples.

Metadata

Release files for tankersdk-user-token 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tankersdk-user-token 0.3
File Size Uploaded Provenance Actions
tankersdk-user-token-0.3.tar.gz 3.9 kB Without provenance Details for tankersdk-user-token-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tankersdk-user-token 0.3
File Interpreter ABI Platform Actions
tankersdk_user_token-0.3-py2.py3-none-any.whl Python 3, Python 2 none any Details for tankersdk_user_token-0.3-py2.py3-none-any.whl

Total release size: 9.7 kB

Release files / tankersdk-user-token-0.3.tar.gz

Download URL tankersdk-user-token-0.3.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dc98a7f3d2f47329eba196e55ce4e69e17d5953690e42fe8aaa4a191455bb36d
BLAKE2b-256 checksum
How to use checksums
7d706ac511044537e35e3a85ac8bbfac6edf2a9b4112bc770ac4c119484adba7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release files / tankersdk_user_token-0.3-py2.py3-none-any.whl

Download URL tankersdk_user_token-0.3-py2.py3-none-any.whl
Size 5.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7f23c01324c71f1a7f1a095c946de2f58763e1cd915b7bb44d08330cbd9841c0
BLAKE2b-256 checksum
How to use checksums
97d0979a975ddb1ca9685258c96880a3c7c6537c98de145444edbedf12121c99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Security for tankersdk-user-token 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page