title: How to generate Signature for the AWS Import API request?
body: <p>According to the AWS Import API docs the request looks like this:</p>
  
  <pre><code>POST / HTTP/1.1
  content-type:application/x-www-form-urlencoded;charset=utf-8
  host: https://importexport.amazonaws.com
  content-length:356
  
  Operation=CreateJob&amp;Manifest=manifestVersion%3A%202.0%0Abucket%3A%20myBucket 
  %0AaccessKeyId%3A%2013Q2729HYRYMYRB3FK02%0AreturnAddress%3A%0A%20%20%20%20name%3A%20 
  Amazon.com%20ATTN%20Joe%20Random%20%0A%20%20%20%20street1%3A%201200%20AAAA%20Ave%20 
  S.%0A%20%20%20%20city%3A%20Seattle%0A%20%20%20%20stateOrProvince%3A%20WA%0A%20%20%20%20 
  postalCode%3A%2098114%0A%20%20%20%20phoneNumber%3A%20206-266-0000%0A%20%20%20%20 
  country%3A%20USA&amp;JobType=Import&amp;AWSAccessKeyId=1111729HYRYMYRB3FK02&amp; 
  SignatureVersion=2&amp;SignatureMethod=%2FVfkltRBOoSUi1sWxRzN8rw%3D
  </code></pre>
  
  <p>As you can see the last parameter in the body data is SignatureMethod. But it looks like Signature. I have found two available values for the SignatureMethod. They are HmacSHA1 and HmacSHA256.</p>
  
  <p>I used the aws/s3 gem in order to generate the Signature query string and finally I've got the request looks like the previous one but with small change at the end.</p>
  
  <pre><code>POST / HTTP/1.1
  content-type:application/x-www-form-urlencoded;charset=utf-8
  host: https://importexport.amazonaws.com
  content-length:356
  
  Operation=CreateJob&amp;Manifest=manifestVersion%3A%202.0%0Abucket%3A%20myBucket 
  %0AaccessKeyId%3A%2013Q2729HYRYMYRB3FK02%0AreturnAddress%3A%0A%20%20%20%20name%3A%20 
  Amazon.com%20ATTN%20Joe%20Random%20%0A%20%20%20%20street1%3A%201200%20AAAA%20Ave%20 
  S.%0A%20%20%20%20city%3A%20Seattle%0A%20%20%20%20stateOrProvince%3A%20WA%0A%20%20%20%20 
  postalCode%3A%2098114%0A%20%20%20%20phoneNumber%3A%20206-266-0000%0A%20%20%20%20 
  country%3A%20USA&amp;JobType=Import&amp;AWSAccessKeyId=1111729HYRYMYRB3FK02&amp; 
  SignatureVersion=2&amp;SignatureMethod=HmacSHA1&amp;Expires=2010-09-16T00:50:54-07:00&amp;Signature=%2FVfkltRBOoSUi1sWxRzN8rw%3D
  </code></pre>
  
  <p>But the response is still 403 Forbidden.</p>
  
  <pre><code>HTTP/1.1 403 Forbidden
  x-amzn-RequestId: c0cb004b-c15e-11df-ad6c-5731ef5a3d54
  Content-MD5: HvqVlJqxxJ5B5A73W4nUCg==
  Content-Type: text/xml
  Content-Length: 439
  Date: Thu, 16 Sep 2010 06:50:55 GMT
  
  &lt;ErrorResponse xmlns="http://importexport.amazonaws.com/doc/2010-06-01/"&gt;
    &lt;Error&gt;
      &lt;Type&gt;Sender&lt;/Type&gt;
      &lt;Code&gt;SignatureDoesNotMatch&lt;/Code&gt;
      &lt;Message&gt;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.&lt;/Message&gt;
    &lt;/Error&gt;
    &lt;RequestId&gt;c0cb004b-c15e-11df-ad6c-5731ef5a3d54&lt;/RequestId&gt;
  &lt;/ErrorResponse&gt;
  </code></pre>
  
  <p>You could find the code I used to test this here <a href="http://gist.github.com/581726" rel="nofollow noreferrer">http://gist.github.com/581726</a></p>
  
  <p>Please advise me what's wrong and how to generate the signature correctly.</p>