我收到以下错误:
<Type>Sender</Type>
<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>
尝试按照http://docs.developer.amazonservices.com/en_US/auth_token/AuthToken_GetAuthToken.html
上的文档进行GetAuthData调用答案 0 :(得分:0)
以下是我能够做到的工作:
修改http://docs.developer.amazonservices.com/en_US/dev_guide/DG_ClientLibraries.html#DG_OwnClientLibrary__Signatures中的calculateStringToSignV2()方法以包含网址的尾随部分
Map<String, String> sorted = new TreeMap<String, String>();
sorted.putAll(parameters);
// Set endpoint value
URI endpoint = new URI(serviceUrl.toLowerCase());
// Create flattened (String) representation
StringBuilder data = new StringBuilder();
data.append("POST\n");
data.append(endpoint.getHost());
data.append("\n/Sellers/2011-07-01"); //YOUR URL
data.append("\n");
Iterator<Map.Entry<String, String>> pairs =
sorted.entrySet().iterator();
while (pairs.hasNext()) {
Map.Entry<String, String> pair = pairs.next();
if (pair.getValue() != null) {
data.append( pair.getKey() + "=" + pair.getValue());
}
else {
data.append( pair.getKey() + "=");
}
// Delimit parameters with ampersand (&)
if (pairs.hasNext()) {
data.append( "&");
}
}
return data.toString();
}
修改parameters.put(“Timestamp”,urlEncode(“2013-05-02T16:00:00Z”));在文档http://docs.developer.amazonservices.com/en_US/dev_guide/DG_ClientLibraries.html#DG_OwnClientLibrary__Signatures中,以便timestamp参数为UTC和ISO-8601
如下所示:
String dt = DateTime.now(DateTimeZone.UTC).toString(DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z"));
parameters.put("Timestamp", urlEncode(dt));
P.S。我花了5-6个小时调试这个问题,并没有通过谷歌找到任何解决方案,所以最好把它放在这里以节省其他人的时间。