This is a small Flask application that implements the OAuth callback flow for BigCommerce Single Click Apps and uses the BigCommerce API to pull a list of products on a BigCommerce store. For information on how to develop apps for BigCommerce stores, see our Developer Portal.
We hope this sample gives you a good starting point for building your next killer app! What follows are steps specific to running and installing this sample application.
- Create a trial store on BigCommerce
- Go to the Developer Portal and log in by going to "My Apps"
- Click the button "Create an app", enter a name for the new app, and then click "Create"
- You don't have to fill out all the details for your app right away, but you do need
to provide some core details in section 4 (Technical). Note that if you are just getting
started, you can use
localhost
for your hostname, but ultimately you'll need to host your app on the public Internet.
- Auth Callback URL:
https://<app hostname>/bigcommerce/callback
- Load Callback URL:
https://<app hostname>/bigcommerce/load
- Uninstall Callback URL:
https://<app hostname>/bigcommerce/uninstall
- Remove User Callback URL:
https://<app hostname>/bigcommerce/remove-user
(if enabling your app for multiple users)
- Enable the Products - Read Only scope under OAuth scopes, which is what this sample app needs.
- Click
Save & Close
on the top right of the dialog. - You'll now see your app in a list in the My Apps section of Developer Portal. Hover over it and click View Client ID. You'll need these values in the next step.
- Clone this repo:
git clone git@github.com:bigcommerce/hello-world-app-python-flask.git
- Change to the repo directory:
cd hello-world-app-python-flask
- If you want to use virtualenv:
virtualenv ENV && source ENV/bin/activate
- Install dependencies with pip:
pip install -r requirements.txt
- Copy
.env-example
to.env
- Edit
.env
:
- Set
BC_CLIENT_ID
andBC_CLIENT_SECRET
to the values obtained from Developer Portal. - Set
APP_URL
tohttps://<app hostname>
. - Set
SESSION_SECRET
to a long random string, such as that generated byos.urandom(64)
.
- Make sure to populate the database by opening a Python shell from within the app and running
from app import db db.create_all()
- Run the app:
python ./app.py
- Then follow the steps under Installing the app in your trial store.
In order to install this app in a BigCommerce store, it must be hosted on the public Internet. You can get started in development
by simply running python app.py
to run it locally, and then use localhost
in your URLs, but ultimately you will need to host
it somewhere to use the app anywhere other than your development system.
- See Registering the app with BigCommerce above. Ignore the callback URLs, just save the app to get the Client ID and Client Secret.
- Deploy the app, and click "view" when it's done
- Take the callback URLs from the instructions page and plug them into the dev portal.
- Then follow the steps under Installing the app in your trial store.
- Login to your trial store
- Go to the Marketplace and click My Drafts. Find the app you just created and click it.
- A details dialog will open. Click Install and the draft app will be installed in your store.