I want the access token saved in a variable to use it to call admin api after a webhook call nodejs

Solved

I want the access token saved in a variable to use it to call admin api after a webhook call nodejs

haseebintegriti
Shopify Partner
8 2 1

I have an app and I am getting the webhook notification when a cart is updated. Now I want to call an rest admin api to update a product information but I'm unable to get the access token of the store. I know we can save the access token in database but for initial testing I want it in a variable to call rest put api.

Accepted Solution (1)

haseebintegriti
Shopify Partner
8 2 1

This is an accepted solution.

To get the access token we can use res.locals.shopify.session and it is also creating a table in sqlite database you can see the database using DB Broswer SQLight. 
To use it on server side to make an api call to shopify you can access it from the database file.  

View solution in original post

Replies 5 (5)

flareAI
Shopify Partner
2405 224 543

Hello @haseebintegriti,

 

I am Gina from flareAI app helping Shopify merchants get $6Million+ in sales from Google Search, on autopilot.


The access token is generated when you are adding the app. If you have not saved it to the database, probably you have missed the token and you can't retain it.


I would advise saving the access token while the app is added to a store. In your case, you can simply remove and add the app again and this time remember to save the generated access token to your database and use it as a variable while making the API calls.


Shopify apps often need to make API calls on behalf of the store even when the user is not actively interacting with the app. Storing the access token in a database allows the app to persistently authenticate and make authorized requests to the Shopify API.


Hope this helps


Gina

flareAI : Get Sales from Google Search, on Autopilot
$10+ billion in eCommerce on Google Search, every day. Find out how much you are missing
haseebintegriti
Shopify Partner
8 2 1

Thank you  @flareAI for helping me out. 
I want to know how I can save the access token in nodejs shopify app boilerplate. Where to add the code to store the access token. Can you share some example code of it in the updated boilerplate template? 
Thank you.

haseebintegriti
Shopify Partner
8 2 1

@flareAI Any help you can provide me in regarding?

flareAI
Shopify Partner
2405 224 543

Hello @haseebintegriti,

 

Gina here from flareAI app


Sorry. I don't know how to get access token in Node js. However, you can take a look at these references.


Build a Shopify app 
Get an access token 


Hope this helps


Gina

flareAI : Get Sales from Google Search, on Autopilot
$10+ billion in eCommerce on Google Search, every day. Find out how much you are missing

haseebintegriti
Shopify Partner
8 2 1

This is an accepted solution.

To get the access token we can use res.locals.shopify.session and it is also creating a table in sqlite database you can see the database using DB Broswer SQLight. 
To use it on server side to make an api call to shopify you can access it from the database file.