title: Error x-amzn-errortype: InvalidSignatureException on DELETE request to API gateway
body: <p>I am attempting to build a javascript application.
  I am unable to get a DELETE request authenticated via IAM. </p>
  
  <p>The API gateway delete route has been configured to use AWS_IAM authentication. Cognito user group has a role attached which grants access to invoke the delete route.</p>
  
  <p><strong>I've signed the request using AWS.Signers.V4</strong></p>
  
  <pre><code>var httpRequest = new AWS.HttpRequest("https://bo5o2odxxx.execute-api.ap-south-1.amazonaws.com/wrhprod/"+uri, "ap-south-1");
  
  httpRequest.headers.host = "https://bo5o2odxxx.execute-api.ap-south-1.amazonaws.com";
  httpRequest.headers['Content-Type'] = "application/json";
  
  httpRequest.method = method; 
  
  var v4signer = new AWS.Signers.V4(httpRequest, "execute-api", true);
  v4signer.addAuthorization(awsCredentials, AWS.util.date.getDate());
  delete httpRequest.headers['host']
  delete httpRequest.headers['X-Amz-User-Agent']
  </code></pre>
  
  <p><strong>I am using axios to send the delete request:</strong></p>
  
  <pre><code>axios.delete('/events/2017/1523502329582',
  { headers: httpRequest.headers})
  .then(response =&gt; {
  //success
  })
  .catch(error =&gt; {
  //fail
  });
  </code></pre>
  
  <p><strong>This is my request Header:</strong></p>
  
  <pre><code>:authority: bo5o2odxxx.execute-api.ap-south-1.amazonaws.com
  :method: DELETE
  :path: /wrhprod/events/2017/1523502329582
  :scheme: https
  accept: application/json, text/plain, /
  accept-encoding: gzip, deflate, br
  accept-language: en-US,en;q=0.9
  authorization: AWS4-HMAC-SHA256 Credential=ASIAIGIXC2II7KWVVUVA/20180413/ap-south-1/execute-api/aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token;x-amz-user-agent, Signature=f1b12cf3c1a3693f259e2f0079231974d6de0e4225bca0af3754a32eecf95277
  origin: http://localhost:3000
  referer: http://localhost:3000/events
  user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
  x-amz-date: 20180413T071741Z
  x-amz-security-token: AgoGb3JpZ2luEAw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E5CVx3bkdRlEObRXB/DyCv+gfk3VfouIchF8xNpMU1jmaHN5+rB0/lbTMxVmEX8qYc6UdZXIIWRm2spB2YwnacBhC0Q36CnCwU1hcRo7YhcminiCPQy6+7OrOTLLXKAenRjNIuPYGAaZQl1MgPMBwFpPGAdbrJG/iWleNf5fN+dettOD18VT8jrmdQ0jRM5N9OjEMJqvwdYF
  </code></pre>
  
  <p><strong>This is the AWS response header:</strong></p>
  
  <pre><code>content-length: 192
  content-type: application/json
  date: Fri, 13 Apr 2018 07:17:41 GMT
  status: 403
  x-amz-apigw-id: FRLvXEDeBcwFuLQ=
  x-amzn-errortype: InvalidSignatureException
  x-amzn-requestid: c0f040c3-3eea-11e8-bd7a-dd445896cd03
  </code></pre>
  
  <p>I've spent hours on this &amp; have not found a solution, please let me know if I can supply any other information to help troubleshoot.</p>
  
  <p>This same API was working using cognito as an API gateway authorizer, I switches to IAM so that I may have more fine grained control on the cognito users.</p>