Saving A Shop's App Shopify Api Key

ged12345
New Member
6 0 0

Hey guys,

I'm developing a Shopify app and I'm no really understanding how to access a shop's API key and secret. At the moment I have a test shop that I've installed my dev app on. Within that app, there's a .env file that contains my shop's API key and secret. I want to farm some of the work off to a server and schedule specific tasks via data saved to  a database which is basically a queue that is converted into cronjobs.

However, externally I believe I will need the API key and secret for the shop that has installed my purchased app to make any sorts of API calls on behalf of the shop.

I may be way off-base here as to how this process works but I really need this functionality if my app is going to scale. Any help y'all could give me about what happens once my app is up on the App store and what processes I need to follow to implement external jobs in the way I've described would be great.

Thanks!

Rob

0 Likes

Hi. If I understood the question correctly, then the documentation for developing an app with React will help you understand the very idea of these keys.

1) Configuring keys in Shopify - https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react/embed-your-app-in-shopify#get-... 

2) Add to .env - https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react/embed-your-app-in-shopify#add-... 

3) Then in a section Set up a Node.js server step 5.

3.jpg

These keys are used for authentication. In the application itself, you need to use "accessToken" (in green block on screen). And this is what should be saved in the DB and used, if necessary, on the server side.

 

Of course, there are some differences when developing an application in different programming languages, but this documentation gives enough to understand the principles of application operation.

Rob1231
New Member
3 0 0

Hey Rob, 

I think what you mean is you want an off-line oauth token as opposed to an online one. Off line tokens don't expire, so you can use them externally, whereas online tokens only exist while the user is accessing the app interface via your Admin Panel. 

You'll be able to store (and please store this securely, I might add) the token for later re-use when you run your cron jobs etc. 

 

https://shopify.dev/concepts/about-apis/authentication

 

0 Likes