Database for an shopify app

Excursionist
30 1 1

Hi newbie here,

I have some question. Hope that someone could explain to me. I want create an app and sell it to x store.

 

+ Does shopify help store shop' s access token and their url  or I have to create one to store it ?

+ If my app want to do something in the front end (for example: write a comment or a review, like a product, ... ) . How it will communicate with my app's database ?

+ Does access token is permanent ?

 

Thank in advance

0 Likes
Shopify Partner
97 4 32

One by one:

 

1. Access tokens - if you mean an environment variable that they provide somehow, then no - remember that an app, while displayed in a merchant's admin panel, is still running on your server (hence the term "embedded app"). So the "environment" is on your machine, not theirs. It's up to you to declare environment variables for your credentials (often you'd set 'SHOPIFY_API_KEY' and 'SHOPIFY_API_SECRET_KEY' in a .env file, and import it into React/whatever later).

2. In the same way you can communicate information to a database in any other JavaScript app. You create an API endpoint of your server that accepts a GET/POST/PUT request, you add authentication so that not everybody can use that API, and do 'fetch' / 'axios' from somewhere in your page to get the data in from the database or send it out. Shopify is really agnostic to the database and server you use for your app - all they care about is that you don't overload the page with redundant JavaScript, and not overload their servers with needless requests (which is why GraphQL is now a thing in Shopify). Bring your own stack (I personally use Apache + MySQL running on a cheap AWS EC2 instance, but if I wanted to swap to Nginx + Postgres running on Google Cloud platform tomorrow, that won't change a thing - I'd just have to make sure the endpoint I created is still the same endpoint).
3. That's actually a good question I've never thought about before. As far as i know (and that's just from my experience and looking in https://help.shopify.com/en/api/getting-started/authentication/private-authentication and https://help.shopify.com/en/api/getting-started/authentication/private-authentication and https://help.shopify.com/en/api/getting-started/authentication/public-authentication for private and public apps, respectively) there is no expiration time for a Shopify API Key, a Shopify API Secret Key, or a Shopify Access Token. However, it's perfectly reasonable to assume that those tokens expire on Shopify's Backend at some point, and you will be prompted to generate new ones. It just never happened to me personally. Maybe @Dirk or someone else from the Shopfiy team can come in and answer this?

Building custom, public-facing Shopify Apps for various niches. Ping me with your app ideas!

My Apps:
* Countries We Ship To Button (Free!) - Show your customers where you ship to with a crisp button + pop-up!


My Tutorials:
* Get Notified When New Comments Are Added To Your Shopify Blog (Free!) - A quick & easy tutorial to set up a free web-service that e-mails you when you get a new comment on your Shopify blog!
1 Like