import requests from datetime import datetime import hashlib import hmac import base64 import pytz API_KEY = '' BASE_URL = 'https://app.choozle.com/api' EMAIL = 'email address' AUTHORIZATION_URL = '%s/auth' % BASE_URL def get_auth_token(email, secret): timestamp = float(datetime.now().strftime('%s')) timestamp = datetime.fromtimestamp(timestamp, pytz.UTC).isoformat() msg = '%s%s' % (email, timestamp) message = bytes(msg, encoding='utf8') secret = bytes(secret, encoding='utf8') signature = hmac.new(secret, message, digestmod=hashlib.sha256).hexdigest() print('Token: %s' % secret) print('Timestamp: %s' % timestamp) print('Email: %s' % email) print('Signature: %s\n' % signature) data = {'email': email, 'timestamp': timestamp, 'signature': signature} print(AUTHORIZATION_URL) print(data) response = requests.post(url=AUTHORIZATION_URL, data=data) return response token_response = get_auth_token(EMAIL, API_KEY) print(token_response.text)