Skip to content

Instantly share code, notes, and snippets.



Last active Feb 17, 2021
What would you like to do?
Generating Cloudtrax API authorization/signature header with Python (client-side)
from time import time
import hmac
import hashlib
import uuid
def get_authorization_header(key: str) -> str:
nonce = 'YOUR_NONCE_PREFIX' + str(uuid.uuid4())
authorization = "key=" + key + ",timestamp=" + str(int(time())) + ",nonce=" + nonce
return authorization
def get_signature_header(authorization_header: str, path: str, secret: str):
signature =, 'UTF-8'), bytes(authorization_header + path, 'UTF-8'), hashlib.sha256).hexdigest()
return signature
key = 'API_KEY_HERE'
secret = 'SECRET_KEY_HERE'
path = '/network/list' # change this for every desired api resource/path
authorization_header = get_authorization_header(key)
signature_header = get_signature_header(authorization_header, path, secret)
print('Authorization Header: {}'.format(authorization_header));
print('Signature Header: {}'.format(signature_header));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment