【问题标题】:passport-linkedin callback does not work护照-linkedin 回调不起作用
【发布时间】:2016-01-20 03:26:25
【问题描述】:

我正在使用 passport-linkedin 将 LinkedIn 帐户集成到我的项目中。问题是当我的数据库中没有找到linkedin电子邮件时,我需要在回调函数中显示linkedin帐户信息。

passport.js

passport.use(new LinkedInStrategy({
    consumerKey: '12121',
    consumerSecret: '1212121',
    callbackURL: "/auth/linkedin/callback",
    profileFields: ['id', 'first-name', 'last-name', 'email-address', 'headline']
  },
  function(token, tokenSecret, profile, done) {
        auth.findOne({ username: profile.emails[0].value }).then(function (err, user) {
            if (!user) {
                return done(null, profile);
            } else {
                return done(null, user);
            }
        }, function (err) {
            return done(err, null);
        })
    }
));

routes.js

app.get('/auth/linkedin/callback', 
    passport.authenticate('linkedin', { failureRedirect: '/login' }),
        function(req, res) {
        winston.error('linkedInfo: %s', req);
        res.redirect('/');
  });

在 routes.js 中,我想显示来自 LinkedIn 的所有 json 数据。但是没有任何东西显示为根本不工作。

【问题讨论】:

    标签: javascript node.js linkedin passport.js


    【解决方案1】:

    如果您想返回成员的电子邮件地址,需要检查的一点是确保您在 OAuth 过程中请求 r_basicprofiler_emailaddress 成员权限。

    由于您没有必要的权限来请求您要求的所有字段,因此整个调用可能会失败(并通过 Passport 层隐藏)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-05
      • 2018-12-07
      • 2015-12-13
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 2020-09-21
      相关资源
      最近更新 更多