Step 1. Setting up your database to store tokens.
If we are going to be asking Shopify for a security token, we are going to need to store it somewhere. It’s best to start by creating a new field in your database structure where you will store the token.
Depending on your use case, you might be storing this against an individual user, or perhaps against a team or a company if your app allows multiple users.
Incidentally, this is another benefit of handling your own authentication - you can allow multiple users from the same team/company to use the same token.
This means if one user grants my app permission in Shopify, all other users of the system from that company will benefit and be able to query data from Shopify.
As you can see, in my app I am going to attach my ‘Shopify Token’ field to my ‘Company’ entity in the database. There is another field called ‘Shopify Security State’ which we will use to store a random string we use during the authentication process.
Note: Make sure you have your privacy rules set up in correctly in Bubble - you need to ensure any API tokens you are storing in your app are properly secured.