5

我正在努力将 Amazon 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

我正在使用带有 node.js 后端的咖啡脚本编写此内容。谁能发现我做错了什么?如果需要,我可以发布我的代码。

4

2 回答 2

3

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

于 2012-09-13T20:42:47.850 回答
3

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

于 2014-05-22T07:32:00.177 回答