How to save access token of shopify nodejs app during installation in a variable or in Database?

Solved

How to save access token of shopify nodejs app during installation in a variable or in Database?

haseebintegriti
Shopify Partner
8 2 1

I want to save the access token of a shopify store and shop name in a variable of in a database when someone installs the app on his store. I am using Nodejs boilerplate. I am unable to get the access token to call an api when a webhook is received. 

Thanks

Muhammad.Haseeb@integriti.io
Accepted Solution (1)

haseebintegriti
Shopify Partner
8 2 1

This is an accepted solution.

Nodejs Shopify app template is already handling to save the access token into the database on installation of the app to any store. 

To view the database we can use DB Brower SQLight.
We can access details from the database using res.locals.shopify.session and while making an admin api call from the server end e.g to call an api when a webhook call is received you can simply fetch the access token from the database. 

We need to handle the database while installation we need to check the database using the shop name if it is already exist in it then we will just update the access token every time the app is installed on any shopify store. 

Muhammad.Haseeb@integriti.io

View solution in original post

Replies 3 (3)

oscprofessional
Shopify Partner
16115 2409 3121

Hello @haseebintegriti 

Recently, Shopify provides App Template. So you should migrate from Nodejs boilerplate to Shopify App Template.

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free
haseebintegriti
Shopify Partner
8 2 1

Yes. I am using the shopify app template.  
Shopify/shopify-app-template-node (github.com)

Muhammad.Haseeb@integriti.io

haseebintegriti
Shopify Partner
8 2 1

This is an accepted solution.

Nodejs Shopify app template is already handling to save the access token into the database on installation of the app to any store. 

To view the database we can use DB Brower SQLight.
We can access details from the database using res.locals.shopify.session and while making an admin api call from the server end e.g to call an api when a webhook call is received you can simply fetch the access token from the database. 

We need to handle the database while installation we need to check the database using the shop name if it is already exist in it then we will just update the access token every time the app is installed on any shopify store. 

Muhammad.Haseeb@integriti.io