【问题标题】:InternalOAuthError when using passport-linkedin strategy使用passport-linkedin策略时的InternalOAuthError
【发布时间】:2015-08-16 22:06:10
【问题描述】:

我正在使用 passport-linkedin,但出现此错误。

InternalOAuthError: failed to obtain request token
    at /Users/davey/code/node/appify-frontend/node_modules/passport-linkedin/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:196:36
    at /Users/davey/code/node/appify-frontend/node_modules/passport-linkedin/lib/passport-linkedin/strategy.js:80:19
    at passBackControl (/Users/davey/code/node/appify-frontend/node_modules/passport-linkedin/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:397:13)
    at IncomingMessage.<anonymous> (/Users/davey/code/node/appify-frontend/node_modules/passport-linkedin/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:409:9)
    at IncomingMessage.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)
GET /oauth/linkedin 500 1074ms - 786b

这是我的设置的样子

exports.setup = function (config) {
  var passport = require('passport');
  var LinkedinStrategy = require('passport-linkedin').Strategy;

  passport.use(new LinkedinStrategy({
      consumerKey: config.linkedin.clientID,
      consumerSecret: config.linkedin.clientSecret,
      callbackURL: config.linkedin.callbackURL
    },
    function(token, tokenSecret, profile, done) {
      console.log(token, tokenSecret, profile);
      return done(null, true);
    }
  ));
};

我的路由设置如下

router
    .get('/', 
        function(req, res, next) {
            console.log("[OAuth2:redirect:query]:", JSON.stringify(req.query));
            console.log("[OAuth2:redirect:body]:", JSON.stringify(req.body));
            next();
          },
        passport.authenticate('linkedin', {
        failureRedirect: '/settings/connected-accounts',
        session: false
    }))

    .get('/callback', passport.authenticate('linkedin', {
        failureRedirect: '/settings/connected-accounts',
        session: false
    }), function (req, res){
        res.redirect('/settings/connected-accounts');
    });

在同一个应用程序中,我设置了 twitter 和 facebook oauth,两者都运行良好。我不知道是什么导致了这个错误,并且已经尝试了所有方法。

在我的linkedin 开发者帐户中,我已经按照应有的方式配置了所有内容。

授权重定向 URL:

http://testdomain.ngrok.io/oauth/linkedin/callback

默认“接受”重定向 URL:

http://testdomain.ngrok.io/settings/connected-accounts

我首先使用了在端口 9000 上运行的 localhost url,但是当失败时,我将本地运行的应用程序暴露给了一个实时 url,但我仍然遇到同样的错误。 任何帮助表示赞赏。谢谢

【问题讨论】:

  • 您出现此错误多长时间了? LinkedIn 上可能有什么问题?
  • 这样已经有 15 个小时了

标签: node.js oauth passport.js linkedin-api


【解决方案1】:

InternalOAuthError 与 passport-oauth1 (https://github.com/jaredhanson/passport-linkedin/blob/master/lib/strategy.js) 相关,但您根据路由设置使用 OAuth2。所以尝试切换到passport-linkedin-oauth2

【讨论】:

    猜你喜欢
    • 2020-03-24
    • 2021-05-28
    • 2020-01-31
    • 2019-09-30
    • 2017-06-08
    • 2023-03-25
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多