jaredhanson / passport-facebook

Facebook authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-facebook/?utm_source=github&utm_medium=referral&utm_campaign=passport-facebook&utm_content=about
MIT License
1.29k stars 447 forks source link

add state support #215

Closed MoreBlood closed 7 years ago

MoreBlood commented 7 years ago

This param is used for validation, in my case for identifying client id https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#logindialog so to use it simply add req param to callback function

passport.use(new FacebookStrategy({
  clientID: CLIENT_ID,
  clientSecret: CLIENT_SECRET,
  callbackURL: CALLBACK_URL,
  passReqToCallback: true, //add this to get req
},
  ((req, accessToken, refreshToken, profile, done) => {
    const state = req.query.state;
    ...
coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.8%) to 99.18% when pulling c10b525b42ccb1356f50cec42b9587b9d38ae72b on MoreBlood:master into 90a642b4738367f929fc2df05a1c3203cd7df38f on jaredhanson:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.8%) to 99.18% when pulling c10b525b42ccb1356f50cec42b9587b9d38ae72b on MoreBlood:master into 90a642b4738367f929fc2df05a1c3203cd7df38f on jaredhanson:master.

ryanwarsaw commented 7 years ago

If I recall correctly there is an internal parameter state that if you set to true, will automatically generate and handle all of that for you.

jaredhanson commented 7 years ago

State support is built into the parent OAuth2Strategy.