This repo is an example of how to build a QuickNode Marketplace add-on using Python and Flask.
It implements the 4 provisioning routes that a partner needs to integrate with Marketplace, as well as the required Healthcheck route.
It also supports:
- RPC methods via a
POST /rpc
route - A dashboard view with Single Sign On using JSON Web Tokens (JWT).
To install and run the application locally:
- Clone the repository.
- Create a virtual environment:
python -m venv venv
. - Activate the virtual environment:
source venv/bin/activate
. - Install the required packages:
pip install -r requirements.txt
. - Copy
.env.example
to.env
file and fill inDB_URL
,AUTH_USERNAME
, andAUTH_PASSWORD
with the appropiate values. - Run the application:
flask run
.
The application has 4 provisioning routes protected by HTTP Basic Auth:
POST /provision
PUT /update
DELETE /deactivate
DELETE /deprovision
It has a public healthcheck route that returns 200 if the service and the database is up and running:
GET /healthcheck
It has a dashboard that can be accessed using Single Sign On with JSON Web Token (JWT):
GET /dashboard?jwt=foobar
It has an JSON RPC route:
POST /rpc
You can use the qn-marketplace-cli tool to quickly test your add-on while developing it.
To obtain a basic auth string, you can use Python or your language of choice with your username and password, as such:
import base64
username = "username"
password = "password"
auth_string = f"{username}:{password}"
encoded_bytes = base64.b64encode(auth_string.encode('utf-8'))
encoded_string = encoded_bytes.decode('utf-8')
print(encoded_string)
For the commands below, the --basic-auth
flag is the Base64 encoding of username:password
.
You need to make sure to replace that with your valid credentials (as defined in your .env
file).
PUDD:
./qn-marketplace-cli pudd --base-url http://localhost:3015 --basic-auth dXNlcm5hbWU6cGFzc3dvcmQ=
SSO:
./qn-marketplace-cli sso --url http://localhost:3015/provision --jwt-secret jwt-secret --basic-auth dXNlcm5hbWU6cGFzc3dvcmQ=
RPC:
./qn-marketplace-cli rpc --url http://localhost:3015/provision --rpc-method qn_test --rpc-url http://localhost:3015/rpc --rpc-params "[\"abc\"]" --basic-auth dXNlcm5hbWU6cGFzc3dvcmQ=
Healthcheck:
./qn-marketplace-cli healthcheck --url http://localhost:3015/healthcheck
MIT