Getting the above error when trying to authenticate a new user using LinkedIn's oAuth 2.0. It looks like I'm getting passed a 10 digit ObjectId instead of a 12 or 24 character id...
passport.use(new LinkedInStrategy({
clientID: process.env.LI_ID,
clientSecret: process.env.LI_SECRET,
callbackURL: "http://localhost:3000/auth/linkedin/think-it",
scope: ['r_emailaddress', 'r_liteprofile'],
state: true
}, function(accessToken, refreshToken, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
// To keep the example simple, the user's LinkedIn profile is returned to
// represent the logged-in user. In a typical application, you would want
// to associate the LinkedIn account with a user record in your database,
// and return that user instead.
return done(null, profile);
});
}));
I'm getting hung up at:
passport.deserializeUser(function(id, done) {
User.findById(id, function(err, user) {
done(err, user);
});
});
Resolved. I was not returning a user from my DB. From the code above:
...function(accessToken, refreshToken, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
//code below was not present when I was getting the error:
User.findOrCreate({ linkedInId: profile.id}, function(err, user) {
if (err) { return done(err); }
done(null, user);
});
});