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.

Source Distribution

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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

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