January 3, 2017

aws signature v4 troubleshooting string to sign

If you're trying to use Amazon AWS Signature Version 4 class and it throws you a 403 Forbidden error, you need to troubleshoot your request. As suggested in the official troubleshooting guide, you'll have to compare your string-to-sign with the one AWS expects. The latter will be present in their response body.

To get the former, find a SignatureV4.php file on your system and var_dump() the $toSign variable here:
https://github.com/aws/aws-sdk-php/blob/master/src/Signature/SignatureV4.php#L50

Compare your string-to-sign with Amazons. If they match, but you're still getting the 403 Forbidden error, try regenerating your Secret access key.

No comments: