Nest.Js w/ @nestjs-shopify/webhooks: 401 Invalid HMAC

tictac232434
Shopify Partner
2 0 0

Hey guy's,

 

I currently have the customers/create webhook handler in Nest.Js working through the shopify cli with

 

shopify webhook trigger --topic customers/create --api-version 2023-07 --client-secret ${secret} --delivery-method http --address http://localhost:4110/shopify-webhooks

This would work for my testing use case but it comes with a default user with default data bob@biller.com. Is there a way to change this to another users data?

 

Otherwise, on to my manual approach to use Insomnia to manually create the webhook request.

 

Here is my HMAC generation code

 

export function shopifyHMAC({ hmac, secret }: any): string {
  return crypto.createHmac('sha256', hmac).update(JSON.stringify(secret), 'utf-8').digest('base64');
}

Here is my Insomnia attempts with the headers shown in the Shopify Docs.

 

Any help or guidance would be greatly appreciated.

 

Screenshot 2024-02-16 at 10.59.18 AM.pngScreenshot 2024-02-16 at 10.59.26 AM.png

 

Respectfully,

Thomas

 

Replies 3 (3)

Liam
Shopify Staff
2731 297 768

Hi Thomas,

 

Trying to understand this issue a bit more - are you always seeing bob@biller.com appearing when the webhook fires, or only when a test webhook fires?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

tictac232434
Shopify Partner
2 0 0

I am seeing that for the test webhook. Is there a way to modify the payload for the test webhook? Or is there something I am missing for manually creating an HTTP payload through Insomnia?

Liam
Shopify Staff
2731 297 768

For a test of the webhook - it will always be the default email address. You could run your own test by manually creating a "test" customer with the email you want, check the webhook, and then delete the test customer?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog