Re: Authenticate from app extension request

How to authenticate an API call from an app extension request in NodeJs?

nvent97
Tourist
4 0 3

Hello everyone!

I'm trying to perform some actions as an extension from the orders detail page, also I have a NodeJs app created with CLI default command.

After I get the request from Shopify (performed when the user click on the custom action) I want to make an API call to the Shopify admin, specifically the orders API.

But the problem I have is that I can't get the access token I usually got from the loadCurrentSession method because I do authenticated request with axios, also I can't get the token to call the backend and make the request authenticated.

Here are the params I receive from Shopify, maybe there is something I am not seeing which can't be used to authenticate the request (to the backend or directly to Shopify API):

 

{
    "hmac": "042f9XXXX...",
    "host": "Y29ycXXX....",
    "id": "3760000...", //=> This is the order id
    "locale": "en-US",
    "session": "4e1bf7d9XXXX...", 
    "shop": "xxxxx.myshopify.com",
    "timestamp": "1635969268"
}

 

Thanks in advance for your help!

 

Replies 3 (3)

alifaiz1804
Shopify Partner
12 0 3

Hi Nvent97, Same issue here. Do you find any solution? if so please share.

nvent97
Tourist
4 0 3

Hello, I've found out that if I click on the without previously open the app, then the request isn't authenticated.

 

On the other hand, if after I run the app I open it from the apps list and then click on the app extension link then the request is authenticated and can access all of the Shopify features.

 

Regards

alifaiz1804
Shopify Partner
12 0 3

Hi thanks for you reply. Can you please share a snippet of code where you get order number and shop name from custom link parameters. It helps me a lot. Thanks