Forum Discussion
Admine
Neophyte
2 months ago// Generate the signature and build the Auth header var signature = btoa(CryptoJS.HmacSHA256(request_vars,api_key).toString()); var auth = "LMv1 " + api_id + ":" + signature + ":" + epoch; -> took me way too long to get this one but in Python that would be:
def logicmonitor_api(method: str,
resource_path: str,
query_params: str = "",
data: str = "") -> dict:
epoch = str(int(time.time() * 1000))
to_sign = method.upper() + epoch + data + resource_path
hmac_obj = hmac.new(access_key.encode('utf-8'),
to_sign.encode('utf-8'),
hashlib.sha256)
hex_sig = hmac_obj.digest().hex()
signature = base64.b64encode(hex_sig.encode('utf-8')).decode('utf-8')
auth_header = f"LMv1 {access_id}:{signature}:{epoch}"