title: Amazon S3 Error: The request signature we calculated does not match the signature you provided. Check your key and signing method
body: <p>I am trying to get an object from my bucket but I always get the &quot;signature does not match&quot; error. I got my signature generation function from <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-examples-using-sdks.html" rel="nofollow noreferrer">AWS sample code</a> so I am sure that this works. I also tested the upload function and it works. I am only having trouble with the get object function. I spent a huge amount of hours verifying all scenarios/answers in this <a href="https://stackoverflow.com/questions/30518899/amazon-s3-how-to-fix-the-request-signature-we-calculated-does-not-match-the-s">post</a> but nothing worked. So here I am seeking your help.</p>
  <p>Am I missing something in the headers? Here is a sample canonical request that gets created:</p>
  <pre><code>GET
  /index.html
      
  host:&lt;bucketname&gt;.s3.amazonaws.com
  x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
  x-amz-date:20211127T120453Z
      
  host;x-amz-content-sha256;x-amz-date
  e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
  </code></pre>
  <p>EDIT1:</p>
  <p>I tried the <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-examples-using-sdks.html" rel="nofollow noreferrer">AWS sample code</a> by compiling it using <code>javac</code>, then ran it, the get object function works fine. But when added into my Android project, it does not work. To make sure that I copy the sample code as is, I generated its jar file and included the resulting jar file in my project. Still, same issue. This is frustrating. Argg!</p>
  <p>EDIT2: Minimal reproducible example</p>
  <ol>
  <li>Download the sample code from the link above</li>
  <li>Add the code into your Android project except for <code>com.amazonaws.services.s3.sample.RunAllSamples</code> class.</li>
  <li>Add this call in one of your activities: <code>GetS3ObjectSample.getS3Object(&lt;bucketName&gt;, &lt;regionName&gt;, &lt;awsAccessKey&gt;, &lt;awsSecretKey&gt;);</code></li>
  </ol>