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.

Files for tankersdk-user-token, version 0.3
Filename, size File type Python version Upload date Hashes
Filename, size tankersdk_user_token-0.3-py2.py3-none-any.whl (5.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size tankersdk-user-token-0.3.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page