Search code examples
phplaravelamazon-web-servicesamazon-sqsaws-php-sdk

AWS SQS error : SignatureDoesNotMatch HTTP error: 403


I'm working on a face tracking thought video AWS Rekognition (StartFaceSearch). It will return the job id. I have setup everything SQS SNS parts. Here my problem is i can't able to get a message from SQS using receiveMessage(). Even listQueues() also not working. It gives this below error.

"ListQueues" on "https://sqs.us-east-1.amazonaws.com"; AWS HTTP error: Client error: POST https://sqs.us-east-1.amazonaws.com resulted in a 403 Forbidden response: < ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">Sender< Code >S (truncated...) SignatureDoesNotMatch (client): 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.

The Canonical String for this request should have been 'POST / ....... < continue.............

The code as follow. AWS PHP SDK ver 3.64.11.

$queueUrl = "https://sqs.us-east-1.amazonaws.com/xxxxxxx/facetrackingreceive";
        // Get the client from the builder by namespace
        $sqs_client = new SqsClient(array(
            'credentials' => array(
                'key'    => 'xxxxxxxxxx',
                'secret' => 'xxxxxxxxxxxxxxxxxxxxxxx',
            ),
            'version' => '2012-11-05',
            'region'  => 'us-east-1',
            'http' => [ 'verify' => false ],

        ));

        $result = $sqs_client->listQueues();

        foreach ($result->get('QueueUrls') as $queueUrl) {
            echo "$queueUrl\n";
        }

Thanks in advance!


Solution

  • I have solved the problem by regenerating access key. I can't belive it but there is something issue on it. I found that idea from this closed issue. this issue was almost 4 year before now i got same error.

    Problem may occurred due to special characters in access/secret keys

    After regenerating keys in AWS console. SQS all methods works fine with new credentials. Reported this as bug on Github official repository.