title: Amazon S3 - How to fix 'The request signature we calculated does not match the signature' error?
body: <p>I have searched on the web for over two days now, and probably have looked through most of the online documented scenarios and workarounds, but nothing worked for me so far.</p>
  <p>I am on <strong>AWS SDK</strong> for PHP V2.8.7 running on PHP 5.3.</p>
  <p>I am trying to connect to my Amazon S3 bucket with the following code:</p>
  <pre class="lang-php prettyprint-override"><code>// Create a `Aws` object using a configuration file
  $aws = Aws::factory('config.php');
  
  // Get the client from the service locator by namespace
  $s3Client = $aws-&gt;get('s3');
  
  $bucket = &quot;xxx&quot;;
  $keyname = &quot;xxx&quot;;
  
  try {
      $result = $s3Client-&gt;putObject(array(
          'Bucket' =&gt; $bucket,
          'Key' =&gt; $keyname,
          'Body' =&gt; 'Hello World!'
      ));
  
      $file_error = false;
  } catch (Exception $e) {
      $file_error = true;
  
      echo $e-&gt;getMessage();
  
      die();
  }
  </code></pre>
  <p>My config.php file is as follows:</p>
  <pre class="lang-php prettyprint-override"><code>return [
      // Bootstrap the configuration file with AWS specific features
      'includes' =&gt; ['_aws'],
      'services' =&gt; [
          // All AWS clients extend from 'default_settings'. Here we are
          // overriding 'default_settings' with our default credentials and
          // providing a default region setting.
          'default_settings' =&gt; [
              'params' =&gt; [
                  'credentials' =&gt; [
                      'key'    =&gt; 'key',
                      'secret' =&gt; 'secret'
                  ]
              ]
          ]
      ]
  ];
  </code></pre>
  <p>It is producing the following error:</p>
  <blockquote>
  <p>The request signature we calculated does not match the signature you provided. Check your key and signing method.</p>
  </blockquote>
  <p>I've already checked my access key and secret at least 20 times, generated new ones, used different methods to pass in the information (i.e. profile and including credentials in code) but nothing is working at the moment.</p>