Skip to main content

Tanker user token library

Project description

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.

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

tankersdk-user-token-0.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

tankersdk_user_token-0.3-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tankersdk-user-token-0.3.tar.gz.

File metadata

  • Download URL: tankersdk-user-token-0.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for tankersdk-user-token-0.3.tar.gz
Algorithm Hash digest
SHA256 dc98a7f3d2f47329eba196e55ce4e69e17d5953690e42fe8aaa4a191455bb36d
MD5 a65bc1964580b2a20619f90659010ab7
BLAKE2b-256 7d706ac511044537e35e3a85ac8bbfac6edf2a9b4112bc770ac4c119484adba7

See more details on using hashes here.

File details

Details for the file tankersdk_user_token-0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: tankersdk_user_token-0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for tankersdk_user_token-0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7f23c01324c71f1a7f1a095c946de2f58763e1cd915b7bb44d08330cbd9841c0
MD5 cc320f03d568c0cf4bd1407d545dc493
BLAKE2b-256 97d0979a975ddb1ca9685258c96880a3c7c6537c98de145444edbedf12121c99

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