Skip to main content

Tanker user token library

Project description

User token generation in Python for the Tanker SDK.


With pip:

$ pip install tankersdk-user-token


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

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page