The NodeJS Starter is a pre-configured ExpressJS app to quickly build FreshBooks integrations.
Clone / fork the repo and install dependencies:
$ git clone git@github.com:freshbooks/api-nodejs-starterapp.git
$ cd api-nodejs-starterapp
- ngrok is recommended for the Redirect URI
ngrok http 9999
Grab the url from the output, something like https://<random_characters>.ngrok.io- Create an app using following the steps outlined in the API docs
- The redirect_uri should be the
ngrokurl from above in the formhttps://<random_characters>.ngrok.io/auth/freshbooks/redirect - Required App Scopes
- user:profile:read
- user:billable_items:read
- user:invoices:read
- user:payments:read
- The redirect_uri should be the
- Additionally the
appuses the FreshBooks Node SDK- The SDK is now in npm, however please make sure you use the versions
"@freshbooks/api": "^3.0.0" and "@freshbooks/app": "^3.0.0"
- The SDK is now in npm, however please make sure you use the versions
- Create a
.envfile in the root of your project or rename & replace the vars in the providedsample.envfile with your actual values
touch .env
CLIENT_ID=...
CLIENT_SECRET=...
REDIRECT_URI=https://<random_characters>.ngrok.io/auth/freshbooks/redirect
SESSION_SECRET=...
PORT=...
MONGODB_URI=mongodb://MONGODB_HOST:MONGODB_PORT
The redirect URI configured for the app created must match the Redirect URI variable otherwise an "Invalid URI" error will be reported
- The app uses mongoDB for persisting user data
- The environment is bootstrapped with
docker-compose + Makefile - You may simply do
make upwhich will start theapp+mondoDBready to accept requests
-
Home - https://<random_characters>.ngrok.io
- Hit
Get Startedto Auth with FreshBooks
- Hit
-
Dashboard - https://<random_characters>.ngrok.io/app/dashboard
- List of your invoices, items and payments from FreshBooks
-
Settings - https://<random_characters>.ngrok.io/app/settings
Unlinkto disconnect yourapp
You are very welcome to add/improve functionality . Please open a PR and submit a reasonable description about why it is needed


