passport-fitbit-oauth2

An OAuth2 strategy to connect with Fitbit

Showing:

Popularity

Downloads/wk

34

GitHub Stars

28

Maintenance

Last Commit

5yrs ago

Contributors

5

Package

Dependencies

1

Size (min+gzip)

7.9KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Passport strategy for Fitbit OAuth 2.0

Passport strategies for authenticating with Fitbit using ONLY OAuth 2.0.

This module lets you authenticate using Fitbit in your Node.js Express (or Connect) server applications.

Install

$ npm install passport-fitbit-oauth2

Usage of OAuth 2.0

Configure Strategy

The Fitbit OAuth 2.0 authentication strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a client ID, client secret, and callback URL.

var FitbitStrategy = require( 'passport-fitbit-oauth2' ).FitbitOAuth2Strategy;;

passport.use(new FitbitStrategy({
    clientID:     FITBIT_CLIENT_ID,
    clientSecret: FITBIT_CLIENT_SECRET,
    callbackURL: "http://yourdormain:3000/auth/fitbit/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ fitbitId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'fitbit' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/fitbit',
  passport.authenticate('fitbit', { scope: ['activity','heartrate','location','profile'] }
));

app.get( '/auth/fitbit/callback', passport.authenticate( 'fitbit', { 
        successRedirect: '/auth/fitbit/success',
        failureRedirect: '/auth/fitbit/failure'
}));

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial