Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation updates #2

Open
keneasson opened this issue Aug 25, 2015 · 3 comments
Open

Documentation updates #2

keneasson opened this issue Aug 25, 2015 · 3 comments

Comments

@keneasson
Copy link

In the Documentation the Strategy function should be: FitbitOAuth2Strategy, and scope doesn't work if passed in the use.authentication, but needs to be in the arguments passed to the constructor.

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

passport.use(new FitbitStrategy({
    clientID:     FITBIT_CLIENT_ID,
    clientSecret: FITBIT_CLIENT_SECRET,
    callbackURL: "http://yourdormain:3000/auth/fitbit/callback"
  },

As a Module, this works with the current code base:

var FitbitStrategy = require( 'passport-fitbit-oauth2' ).FitbitOAuth2Strategy;
var config = require('./fitbit_oauth2.js').settings;
module.exports = function(passport) {
    passport.use(new FitbitStrategy({
            clientID:     config.clientID,
            clientSecret: config.clientSecret,
            scope: config.scope,
            callbackURL: config.callbackURL,
        },
        function(accessToken, refreshToken, profile, done) {
            User.findOrCreate({ fitbitId: profile.id }, function (err, user) {
                return done(err, user);
            });
        }
    ));
}
@guumaster
Copy link
Contributor

Doc upated after PR #1.

and scope doesn't work if passed in the use.authentication

Not sure what you mean by that.

@keneasson
Copy link
Author

if i have in my route:
app.get('/auth/fitbit', passport.authenticate('fitbit',
{ scope: ['activity','heartrate','location','profile'] }
));
the FitBit api returns an error that scope wasn't set.
I needed to add scope as a property when I instantiate new FitbitStrategy. (as in my example above.)

@ghost
Copy link

ghost commented May 4, 2016

Thanks for the great package. Please publish this doc change to npm, as npm's page for this package doesn't show the correct require information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants