首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用passportjs检索twitter的电子邮件id

无法使用passportjs检索twitter的电子邮件id
EN

Stack Overflow用户
提问于 2018-03-16 12:51:24
回答 1查看 19关注 0票数 0
代码语言:javascript
复制
const TwitterStrategy = require('passport-twitter').Strategy;

module.exports = (passport, User) => {
  passport.use(new TwitterStrategy({
    consumerKey: 'paLCHei1bz8uG5mzNK3ZmvWy7',
    consumerSecret: 'djwTrPntW6T2hm3EJ6eIvUrqObMSymgKn6B1foMQyNeypjtbIK',
    callbackURL: 'http://localhost:3000/auth/twitter/callback',
    passReqToCallback: true
  }, (req, accessToken, tokenSecret, profile, done) => {
    User.findOne({ 'twitter.id': profile.id }, (err, x) => {
      if (x) return done(null, x);
      var user = {
        image: profile._json.profile_image_url,
        displayName: profile.displayName,
        email: profile.emails[0].value,
        twitter: {
          id: profile.id,
          email: profile.emails[0].value
        }
      };
      User.create(user, (err, x) => done(null, x));
    });
  }));
};
EN

回答 1

Stack Overflow用户

发布于 2018-03-24 19:47:59

您需要在Twitter上的应用程序权限中选中“从用户请求电子邮件地址”复选框。你可以阅读更多关于它的here

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49313428

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档