sookool99
sookool99

Reputation: 262

passport-facebook Strategy.parseErrorResponse

I am trying to set up Facebook authentication and I am getting an error whenever the callback function is called it throws a Strategy.parseErrorResponse at /node_modules/passport-facebook/lib/strategy.js:196:12

There is no message telling me what was wrong. I checked to make sure my clientID and secret were correct (as I seen this may happen if they are wrong).

    passport.use(new FacebookStrategy({
        clientID: myId,
        clientSecret: mySeceret,
        callbackURL: callBackUrl,
        passReqToCallback : true
    }, (req, accessToken, refreshToken, profile, done) => {
        process.nextTick(() => {
            if (req.user) {
            done(null, req.user);
            if (!req.user.facebookId) {
                req.user.facebookId = profile.id;

                req.user.save().then(() => {
                    done(null, req.user);
                });
            } else {
                done(null, req.user);
            }
        } else {
            User.find({where: {facebookId: profile.id}}, function (err,user) {
                return done(err, user);
            });
        }
    });
}));

my routes

app.get('/auth/facebook', passport.authenticate('facebook', { scope: 'email' }));
app.get('/auth/facebook/callback',
    passport.authenticate('facebook', { failureRedirect: '/login' }),
    function (req, res) {
        res.redirect('/');
});

full stack

Error
    at Strategy.parseErrorResponse (/node_modules/passport-facebook/lib/strategy.js:196:12)
    at Strategy.OAuth2Strategy._createOAuthError (/node_modules/passport-oauth2/lib/strategy.js:376:16)
    at /node_modules/passport-oauth2/lib/strategy.js:166:45
    at /node_modules/oauth/lib/oauth2.js:191:18
    at passBackControl (/node_modules/oauth/lib/oauth2.js:132:9)
    at IncomingMessage.<anonymous> (/node_modules/oauth/lib/oauth2.js:157:7)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:188:7)
    at endReadableNT (_stream_readable.js:975:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)

Also, it looks like key is getting passed because it contains the I can see the route that is being called /auth/facebook/callback?code="someReallyLongKey"

Upvotes: 1

Views: 330

Answers (1)

I run into exactly the same issue today. It occurred because my server could not connect to the Mongo database. I restarted the mongod service and everything started to work as expected

Upvotes: 0

Related Questions