为亚马逊fps生成签名

时间:2012-09-12 15:33:14

标签: node.js coffeescript amazon-fps

我正在努力将亚马逊FPS集成到我公司的网站中,但似乎在生成正确的签名方面存在问题。以下是亚马逊的文档所要做的事情: http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/APPNDX_GeneratingaSignature.html

这是我的字符串:

GET\nfps.sandbox.amazonaws.com\n/\nAction=Reserve&AWSAccessKeyId=REMOVED&CallerDescription=Reserve&CallerReference=CallerReference05&RecipientTokenId=254656Example83987&SenderTokenId=553IPMACGAZ2J4N1L7BJ3UMNRFTQU4V9NT4RJCTVADDJKXQ6L1ZAKSIUNPIRTTI1&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-09-12T22%3A29%3A07.623Z&TransactionAmount.CurrencyCode=USD&TransactionAmount.Value=1.00&Version=2010-08-28

这是我发送的HTTP请求:

https://fps.sandbox.amazonaws.com?Action=Reserve&AWSAccessKeyId=REMOVED&CallerDescription=Reserve&CallerReference=CallerReference05&RecipientTokenId=254656Example83987&SenderTokenId=553IPMACGAZ2J4N1L7BJ3UMNRFTQU4V9NT4RJCTVADDJKXQ6L1ZAKSIUNPIRTTI1&Signature=t5r%2BWmV9PdoOGfHhtwLJ5nJ8zo%2BIJL4uWB6MOMpkZLw%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-09-12T22%3A29%3A07.623Z&TransactionAmount.CurrencyCode=USD&TransactionAmount.Value=1.00&Version=2010-08-28

这也是我收到的确切错误:

SignatureDoesNotMatch The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. RequestID - ac476abb-2bc6-4891-8854-e52cf33f8716

我在coffeescript中用node.js后端写这个。谁能找到我做错了什么?如果需要,我可以发布我的代码。

2 个答案:

答案 0 :(得分:3)

我弄清楚我做错了什么。我的查询字段不是自然字节顺序。 AWSAccessKey出现在Action之前。亚马逊的例子向我们展示了我尝试这样做的方式而不是正确的方式。

答案 1 :(得分:3)

我写了一个小的lib来帮助签名请求。也许它对你有用https://github.com/theRemix/aws_signature_utils_js