This example is a working example how to use the fitbit subscription api with node.js. Thanks to Lukas Olson for the fitbit-node module it uses.
Features:
- Authorize users
- Subscribe to scopes (e.g. body and activities)
- Receive webhook events and read the data from fitbit
- All results will be logged to the console
- Node.js
- running ngrok
- Fitbit App https://dev.fitbit.com/apps/new
- Running local redis to store the tokens
Copy the test_skeleton.env
to test.env
and set the variables
npm install .
npm run run
Development version with node-dev
npm run rund
Open /authorize/:user_id
in your browser.
After you gave the app access to your app your server will receive subscriptions from fitbit
Every example endpoint assumes you have a ngrok running on your local machine or your server is available through the internet.
GET /authorize/:user_id
Authorize a new user with your own user_id
.
The page will be redirected to the fitbit login/access form
GET /webhook/?verify=xxx
Fitbit verifies the webhook though this endpoint
POST /webhook/
This endpoint receives the fitbit events of the subscribed users
Version | Date | Description |
---|---|---|
0.0.1 | 2016-04-20 | Initial version |
Name | Description |
---|---|
rsmq | A really simple message queue based on Redis |
rsmq-cli | a terminal client for rsmq |
rest-rsmq | REST interface for. |
redis-notifications | A redis based notification engine. It implements the rsmq-worker to safely create notifications and recurring reports. |
node-cache | Simple and fast NodeJS internal caching. Node internal in memory cache like memcached. |
redis-sessions | An advanced session store for NodeJS and Redis |
obj-schema | Simple module to validate an object by a predefined schema |
connect-redis-sessions | A connect or express middleware to simply use the redis sessions. With redis sessions you can handle multiple sessions per user_id. |
systemhealth | Node module to run simple custom checks for your machine or it's connections. It will use redis-heartbeat to send the current state to redis. |
task-queue-worker | A powerful tool for background processing of tasks that are run by making standard http requests. |
soyer | Soyer is small lib for serverside use of Google Closure Templates with node.js. |
grunt-soy-compile | Compile Goggle Closure Templates ( SOY ) templates inclding the handling of XLIFF language files. |
backlunr | A solution to bring Backbone Collections together with the browser fulltext search engine Lunr.js |
Copyright © 2016 Mathias Peter, http://www.tcs.de
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.