Closed thegoliathgeek closed 5 years ago
not sure whether you still have issues or not. here is an example
` import hashlib import hmac import base64
x = '{"replyToken":"6ec1f778-e92f-487c-9818-bdbe3438f30e","clientId":"alexa-skill","createdAt":1567852244,"deviceId":"5d737888aea17c30a056d759","deviceAttributes":[],"type":"request","action":"setPowerState","value":{"state":"On"}}' s = "a751abdb-e260-4bfd-a42c-60660561123d-3d8e6a30-0f39-42f0-a1ec-e47d47fb1392"
message = bytes(x).encode('utf-8') secret = bytes(s).encode('utf-8')
signature = base64.b64encode(hmac.new(secret, message, digestmod=hashlib.sha256).digest()) print(signature)
`
Python HMAC library requires appSecret string to be encoded into utf-8 or ASCII which results in wrong hmac and mismatch in signature. So please encode appSecret to base64 before creating a new hmac.