title: How to solve HMAC Validation Failed in Shopify App?
body: <p>I followed exactly the code from the shopify docs (<a href="https://help.shopify.com/en/api/tutorials/build-a-shopify-app-with-node-and-express#the-callback-route" rel="nofollow noreferrer">Shopify app with Node and Express</a>) for integrating app with express but it seems that I still hitting HMAC Validation Failed.</p>
  <pre><code>const map = Object.assign({}, req.query);
  delete map['signature'];
  delete map['hmac'];
  const message = querystring.stringify(map);
  const providedHmac = Buffer.from(hmac, 'utf-8');
  const generatedHash = Buffer.from(
    crypto
      .createHmac('sha256',this.configService.get('SHOPIFY_API_SECRET'))
      .update(message)
      .digest('hex'),
    'utf-8'
  );
  let hashEquals = false;
  // timingSafeEqual will prevent any timing attacks. Arguments must be buffers
  try {
    hashEquals = crypto.timingSafeEqual(generatedHash, providedHmac)
    // timingSafeEqual will return an error if the input buffers are not the same length.
  } catch (e) {
    hashEquals = false;
  };
  
  if (!hashEquals) {
    return res.status(400).send('HMAC validation failed');
  }
  </code></pre>
  <p>I'm expecting the code above to work and do not return the error.</p>