Amazon MWS Signature
I have written an application in Delphi in order to sync between multiple storefronts. I seem to have run into an issue when it comes to the signature. My scenario is this:
When i run the Orders API for Amazon, it will accept the signature and download all the orders successfully. I have not had any issues when it comes to this one.
Now when I switch over to the Reports API, it will not except the signature. Here is the signing function i'm using
hmac_SHA256_inits(hmc, FSecretAccessKey);
s := StringToSign;
hmac_SHA256_update(hmc, @(s[1]), Length(s));
hmac_SHA256_final(hmc, hmd);
SetLength(sBin, 32);
for i := 0 to 31
do sBin[i+1] := AnsiChar(hmd[i]);
Result := Base64Encode(sBin);
Result := StringReplace(Result, '+', '%2B', [rfReplaceAll]);
Result := StringReplace(Result, '=', '%3D', [rfReplaceAll]);
I have even run this with the same timestamp as the MWS Scratchpad to compare the signaures, and they come out different. Yet the string to sign is exactly the same, word for word, capitalization as well. I would think it might be the signing routine but then how would the Orders API work without any issue if the routine was wrong? The only major difference I can see in the two is that for the Orders API you have to use
POST /Orders/2011-01-01 ParamterString
and the report one is
POST / ParamterString
Could the solo slash be causing the signing to fail? I've tried everything I can think of to fix this and I'm actually considering abandoning the project at this point in favor of a different language.
Any help would be greatly appreciated
Your problem is most likely in your StringToSign
function. It should look somewhat like this:
StringToSign := 'POST'+ chr(13)+
AmazonMWShost + chr(13) +
'/'+ APIurl + chr(13) +
URLencodedParameters;
Where AmazonMWShost is mws.amazonservices.com
for US merchants. APIurl is an empty string for the Report API and Orders/2011-01-01
for the Order API.
上一篇: 亚马逊MWS
下一篇: 亚马逊MWS签名