Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

646
Visualizações
AWS and Rails: The authorization header is malformed; the Credential is mal-formed

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:

Aws::S3::Errors::AuthorizationHeaderMalformed: The authorization header is malformed; the Credential is mal-formed; expecting "<YOUR-AKID>/YYYYMMDD/REGION/SERVICE/aws4_request".

My 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

My aws initializer (which seems to work fine in both environments):

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)
})

appreciate any advice!

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

This answer is very late but maybe someone will find it useful. The above error is caused when you switch up the AWS KEY ID and the AWS ACCESS KEY.

Use the correct credential in the right place and it should fix your issue.

over 4 years ago · Santiago Trujillo Relatório

0

Things to check:

  • bucket ACLs and bucket policies. Does production match dev?
  • do any of your keys contain slashes, that could be incorrectly parsed?
  • are your dev and production regions different? Does it make a difference if you try a different region?
over 4 years ago · Santiago Trujillo Relatório

0

As the error suggests the credentials is not being set correctly. One possible reason (since in works in development environment) is that the config variables access_key_id and secret_access_key might be environment specific.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda