Reputation: 105
I am trying to access authenticated POST API gateway with postman rest client, but I am getting status 403 with forbidden message.
{ "message": "Forbidden" }
I am using AWS Signature Authentication with AccessKey, SecretKey, AWS Region and Service Name. I don't understand why its not allowing my rest call, is it something to do with my AccessKey and SecretKey pair lacking authorisation?? (My user is Admin thought)
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://xxxxxxxxxx.execute-api.us-west-2.amazonaws.com/dev/score",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "input1=1&input2=2",
CURLOPT_HTTPHEADER => array(
"authorization: AAAA-AAAA-XXX123 Credential=XXXXXXXXXX/20160414/us-west-2/execute-api/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature=sdddddssdddddddddddddddddsdsdsdsdsdsdsdsdsdsd",
"cache-control: no-cache",
"content-type: application/javascript",
"host: xxxxxxxxxx.execute-api.us-west-2.amazonaws.com",
"postman-token: abf462fe-24ae-244d-ba8d-d3e953f0e712",
"x-amz-date: 20160414T084331Z"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Upvotes: 1
Views: 5873
Reputation: 264
It often happens when API is not deployed to API Gateway or you are accessing the wrong path /your-rout instead of /api-name/your-route.
Upvotes: 0
Reputation: 1909
If you set 'API Key Required' option to true, please check below.
Upvotes: 3
Reputation: 7325
If you are using an API Key, make sure you set the "x-api-key" header.
I also had the same problem until I created a Usage Plan and linked the plan to the API stage and the API key.
Upvotes: 3
Reputation: 1273
This can have multiple reasons, would you mind sharing a sample setup where it fails?
Please check the following:
Best,
Jurgen, API Gateway
Upvotes: 1