简体   繁体   中英

InternalOAuthError when using passport-linkedin strategy

I'm working with passport-linkedin and I'm getting this error.

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

Here's what my setup looks like

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);
    }
  ));
};

and my routing setup is as follows

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');
    });

In the same app, I've setup twitter and facebook oauth, both of which work very well. I have no idea what's causing this error and have tried everything.

In my linkedin developer account, I've configured everything as should be.

Authorized Redirect URLs:

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

Default "Accept" Redirect URL:

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

I first used a localhost url running on port 9000, but when that failed, I exposed my app running locally to a live url, but I still had the same error. Any help is appreciated. Thanks

The InternalOAuthError is related to passport-oauth1 ( https://github.com/jaredhanson/passport-linkedin/blob/master/lib/strategy.js ) , but you use OAuth2 according to your routing setup. So try switching to passport-linkedin-oauth2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM