title: AWS and Rails: The authorization header is malformed; the Credential is mal-formed
body: <p>I am trying to access my S3 bucket from a production server. Everything works fine in development, however in my prod console I am getting:</p>
  
  <pre><code>Aws::S3::Errors::AuthorizationHeaderMalformed: The authorization header is malformed; the Credential is mal-formed; expecting "&lt;YOUR-AKID&gt;/YYYYMMDD/REGION/SERVICE/aws4_request".
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>class AwsFileDownloader
    def initialize(args)
      @s3 = Aws::S3::Client.new
      @aws_file_path = ...
    end
  
    def get_file
      temp_file = File.new('temp.csv', 'r+')
      @s3.get_object({bucket: Rails.application.secrets.aws_bucket, key: @aws_file_path}, target: temp_file)
      ...
    end
  end
  </code></pre>
  
  <p>My aws initializer (which seems to work fine in both environments):</p>
  
  <pre><code>require 'aws-sdk'
  
  Aws.config.update({
    region: Rails.application.secrets.aws_region,
    credentials: Aws::Credentials.new(Rails.application.secrets.access_key_id, Rails.application.secrets.secret_access_key)
  })
  </code></pre>
  
  <p>appreciate any advice!</p>