Code Monkey home page Code Monkey logo

fitbit-hapi-demo's Introduction

This is a proof of concept example for using the Fitbit Web API. It demonstrates:

  • Obtaining consent from a user to make requests to the Fitbit Web API using OAuth 2.0 Authorization Code Flow
  • Subscribing to changes in the user's activity data
  • Receiving notifications when the user's activity data is updated

This is not intended to be an example of a idiomatic hapi.js application. It is merely a demonstration of the above core concepts. In other words, don't use this code as the foundation for your next great Fitbit Web API app.

I'm serious. This is not a well structured Node.js application.

This example app uses NeDB, a flat-file database similar to Mongo. It's meant to be easy to demo, not highly scalable.

This example assumes you're using Node.js 4.2.x

To get started

npm install

Fitbit Web API client settings at https://dev.fitbit.com/app

Set your OAuth redirect URI to: /signin

Set your subscriber endpoint URI to: /webhook-receiver

To run locally

FITBIT_OAUTH2_CLIENT_ID=todo_your_fitbit_client_id \ FITBIT_OAUTH2_CLIENT_SECRET=todo_your_fitbit_client_secret \ COOKIE_PASSWORD=todo_put_anything_here \ PORT=8000 \ CLOUD_DIR='./' \ node index.js

To receive notifications locally, you'll need to use a tool like ngrok. ~/Applications/ngrok http 8000

To run on Modulus:

Set the environment variables using the instructions at http://help.modulus.io/customer/portal/articles/1701180-using-environments-variables FITBIT_OAUTH2_CLIENT_ID FITBIT_OAUTH2_CLIENT_SECRET COOKIE_PASSWORD

(PORT and CLOUD_DIR will be automatically added by Modulus)

How non-ephemeral file storage (used by NeDB) works on Modulus: http://help.modulus.io/customer/en_us/portal/articles/1653448-file-storage

fitbit-hapi-demo's People

Contributors

jeremiahlee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.