AWS SignatureDoesNotMatch:我们计算的请求签名与您提供的签名不匹配

时间:2015-09-29 23:16:03

标签: javascript amazon-web-services hmac

我收到了对amazon产品api的GET请求的回复。

    <?xml version="1.0"?>
<ItemSearchErrorResponse xmlns="http://ecs.amazonaws.com/doc/2011-08-01/"><Error><Code>SignatureDoesNotMatch</Code><Message>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.</Message></Error><RequestId>9aff7feb-7f9b-4efb-aece-b595b1b7b0e5</RequestId></ItemSearchErrorResponse>

在我的javascript中,我生成的签名为:

  var paramO = {
    Service:'AWSECommerceService',
    Operation:'ItemSearch',
    AWSAccessKeyId:AccessKeyId,
    AssociateTag:AssociateTag,
    Version:'2011-08-01',
    SearchIndex:'All',
    Keywords:name,
    ResponseGroup:'ItemAttributes,OfferSummary',
    Timestamp:timestamp
  };
  var string='GET\nwebservices.amazon.in\n/onca/xml\n';
  console.log(string+$.param(paramO));
  var hash = CryptoJS.HmacSHA256(string+$.param(paramO), SecretAccessKey);
  var signature = CryptoJS.enc.Base64.stringify(hash);

0 个答案:

没有答案