【问题标题】:NodeJS Passport - Twitter InfoNodeJS 护照 - 推特信息
【发布时间】:2014-10-09 03:08:31
【问题描述】:

我的 twitter 身份验证工作正常,但我需要的不仅仅是用户名和显示名,这只是 Passport 的限制。

我正在尝试这样做:

var newUser =  new User();
newUser.uid = profile.id;
newUser.token = token;
newUser.username = profile.username;
newUser.displayName = profile.displayName;
newUser.profile_image_url = profile.profile_image_url;

如果正在查看护照文件,它会限制您可以使用的数据。我猜如果您使用多种身份验证方法,它是一致的,但我只需要使用 twitter。

passport.use(new TwitterStrategy({ ... },
  function(token, tokenSecret, profile, done) {
    console.log(profile);
    ....
  }
);

如果我只是记录配置文件,那么它会提供所有数据,所以我很困惑如何绕过它。我需要来自 twitter 的完整数据,而不仅仅是护照为我挑选的一些数据,我怎样才能得到这个?

【问题讨论】:

标签: node.js twitter passport-twitter


【解决方案1】:

我有一个适合我的简单解决方案:

var image_url = profile._json.profile_image_url.replace('_normal','');

我知道从这样的字符串中删除 _normal 在逻辑上可能不是最好的方法,但它可以工作并将原始图像 url 存储在数据库中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-13
    • 2015-03-20
    • 2014-05-01
    • 2017-07-17
    • 2023-04-06
    • 1970-01-01
    • 2016-03-18
    • 2018-10-14
    相关资源
    最近更新 更多