Steps on how to execute the below Python script: Do we need to install any libraries on the server? as the below script is providing an output outside of the A360
import datetime
import base64
import hmac
import hashlib
import time
def hmac_sha256(message, key):
key = bytes(key, 'UTF-8')
message = bytes(message, 'UTF-8')
h = hmac.new(key, message, hashlib.sha256)
return base64.b64encode(h.digest()).decode()
def authorization(strAKID, strAKSecret):
strDateNow = datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
print(f"date is: {strDateNow}")
strSignContent = "date: {}".format(strDateNow)
#Compute signature, get authorization
strSignature = hmac_sha256(strSignContent, strAKSecret)
print(f"signature is: {strSignature}")
strAuthorization = '''hmac username="{}", algorithm="hmac-sha256", headers="date", signature="{}"'''.format(strAKID, strSignature)
if __name__ == '__main__':
strAKID = "e2c5b464-5361-40f2-9c8e-bc04962db1a7"
strAKSecret = "I5lGga3vfFW8Nf9HbRHuUnROcga0SnpP"
authorization(strAKID, strAKSecret)