I am referring to Alexa Top Sites Developer Guide and using their sample codes, both PHP and Ruby. I am getting the following SignatureDoesNotMatch
error:
<?xml version="1.0"?>
<Response><Errors><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></Errors><RequestID>28c6b028-c4b6-66a2-f5d8-70d8dc21b8f8</RequestID>
</Response>
I tried two different access keys with the same user and signed up for Alexa Web Information Service, but no luck. I tried the scripts on both Mac OS 10.9 and 10.10, my time settings are set to be automatically updated.
In the PHP code this is the part that generates the signature:
/**
* Generates a signature per RFC 2104
*
* @param String $queryParams query parameters to use in creating signature
* @return String signature
*/
protected function generateSignature($queryParams) {
$sign = "GET\n" . strtolower(self::$ServiceHost) . "\n/\n". $queryParams;
echo "String to sign: \n" . $sign . "\n\n";
$sig = base64_encode(hash_hmac('sha256', $sign, $this->secretAccessKey, true));
return rawurlencode($sig);
}
I am not sure what I am doing wrong.
I figured out that. Root AWS user is able to make the request but not IAM User that I created. I guess root user has an access to Alexa service but not IAM user.