Once approved you will be provided an API key and secret from your account representative.
These can be used to authenticate Stylezone HTTP requests
For more information on Stylezone API endpoints please see this article
Example Stylezone API authentication in Python:
Python version 3.7.8
requests_http_signature version 0.2.0
requests version 2.31.0
from requests_http_signature import HTTPSignatureAuth
import requests
def __create_http_signature(secret, key):
return HTTPSignatureAuth(key=secret,
key_id=key,
algorithm='hmac-sha256')
def request_executor(url, request_type, data=None):
secret = SZ_API_SECRET
key = SZ_API_KEY_ID
session = requests.Session()
if request_type.upper() in ['POST', 'PUT']:
response = session.request(request_type, url, auth=__create_http_signature(secret, key), json=data, allow_redirects=False)
else:
response = session.request(request_type, url, auth=__create_http_signature(secret, key), allow_redirects=False)
if response.status_code in [301, 302, 303, 307, 308]:
return response.headers.get('Location')
elif response.ok:
return response.json()
else:
print(f"Error: url: {url} returned {response.status_code}")
return None