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

163
Visualizações
SHA256 HMAC Request Doesn't Validate - Shopify OAuth

I'm having trouble validating the HMAC signature during Shopify OAuth.

When the merchant clicks "install", they are sent to my oauth URL. The url has params added to it like so:

https:my-appp.com/shopify_oauth?hmac=74dac492e0605a9d547e8e1e58a287a7748ce8e2679c40b8953d72691c3314c9&host=ZGdoYmpkZnNnYmpoLm15c2hvcGlmeS5jb20vYWRtaW4&shop=merchants_store.myshopify.com&timestamp=1654472682

As per the documentation

I strip out the HMAC, rebuild the query string with all other params in alphabetical order. Then I run it through a SHA-256 hash function including my apps secret api key.

var crypto = require('crypto')
                  , text = `host=${properties.keyvalues[0].value}&shop=${properties.thing1}&timestamp=${properties.thing2}`
                  , key = 'PRIVATE_API_KEY'
                  , hash;

var returnValue

var hash = crypto.createHmac('sha256', key).update(text).digest('hex');

//var base64 = Buffer.from(hash).toString('base64');

if (hash === shopifyHmac) {
returnValue = "true"

} else {
returnValue = "false"
}

The problem I'm running into is that the provided HMAC does not match the decoded querystring meaning it fails validation.

I've played around with the order of the URL params, as well as which params are included in the querystring. I've also tried encoding it as a base64 format.

Any idea where I'm going wrong?

about 4 years ago · Juan Pablo Isaza
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