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

Pending Callback #209

Open Millen31 opened 7 years ago

Millen31 commented 7 years ago

Hello,

I've some problem with Passport-Facebook. My Callback is pending for 1 Minute and then the error "FacebookTokenError: This authorization code has been used." appears. But I have this problem with just some users. If I login with my personal account, everything works fine. If I use an test user from Facebook, this error appears.

image

I'm using passport 0.3.2 and passport-facebook": "2.1.1",

My Code:

app.get('/auth/facebook', passport.authenticate('facebook', { scope: ['user_hometown', 'user_friends', 'public_profile', 'email' ] })); app.get('/auth/facebook/callback', passport.authenticate('facebook', { successRedirect: '/', failureRedirect: '/login/' }));

passport.use(new FacebookStrategy({ clientID: config.facebook.clientID, clientSecret: config.facebook.clientSecret, callbackURL: config.facebook.callbackURL, profileFields: ['id', 'displayName', 'first_name', 'middle_name', 'last_name','email', 'photos', 'hometown'] }, function(req, accessToken, refreshToken, profile, done) {...

Does anybody have an idea?

Thank and best regards

kyohei8 commented 7 years ago

Are not you calling done()?

passport.use(new FacebookStrategy({...}, 
function(req, accessToken, refreshToken, profile, done) {
  // do something...

  process.nextTick(function () {
    return done(null, profile);  // <- call this
  });

});