passport-oauth2 icon indicating copy to clipboard operation
passport-oauth2 copied to clipboard

Declare authorizationParams in Strategy configuration

Open bencmbrook opened this issue 8 years ago • 0 comments

I noticed authorizationParams are always declared in the call to passport.authorize in the route handler. Is it possible to declare them in the Strategy options object? It doesn't work today, but if it makes sense, then is this a reasonable feature?

For example, instead of declaring them here:

app.get('/auth/reddit', function(req, res, next){
  passport.authenticate('reddit', {
    state: 'exampleState',     // this
    duration: 'permanent',    // and this
  })(req, res, next);
});

Declare them here:

passport.use(new RedditStrategy({
    clientID: REDDIT_CONSUMER_KEY,
    clientSecret: REDDIT_CONSUMER_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/reddit/callback",
    state: 'exampleState',    // here (this works anyway because state is built in)
    duration: 'permanent'    // and here (doesn't work because it's an authorizationParam)
  },
  function(accessToken, refreshToken, profile, done) {

bencmbrook avatar Jul 07 '17 16:07 bencmbrook