mardi 24 mars 2015

How can I create signature for AWS API in javascript usign HmacSHA256?

I'm trying to make a request to AWS API using Javascript, and starting with their examples provided here


I'm using hmac-sha256.js library for that too.


Here is the code:



var today = new Date();
time = today.toISOString();
time = encodeURIComponent(time);

var messageToEncrypt ="GET\nwebservices.amazon.com\n/onca/xml\nService=AWSECommerceService&AWSAccessKeyId=ACCESS&Operation=ItemLookup&ItemId=0679722769&ResponseGroup=SalesRank&Version=2013-08-01&Timestamp="+time;

var sig = CryptoJS.HmacSHA256(messageToEncrypt, "MY SECRET KEY");

var request = "http://ift.tt/1Ncnacm"+time+"&Signature="+sig;


I've used this library with the example which is provided in Amazon but I didn't get the same signature they provieded with dummy secrect access 1234567890


Am I missing something here?





Aucun commentaire:

Enregistrer un commentaire