【发布时间】:2022-01-21 07:31:25
【问题描述】:
尝试使用 LinkedIn 的 oAuth 2.0 对新用户进行身份验证时出现上述错误。看起来我正在传递一个 10 位的 ObjectId 而不是 12 或 24 个字符的 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);
});
}));
我要挂断电话了:
passport.deserializeUser(function(id, done) {
User.findById(id, function(err, user) {
done(err, user);
});
});
【问题讨论】:
标签: javascript mongoose oauth-2.0 passport.js linkedin