question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InternalOAuthError - failed to obtain request token

See original GitHub issue

I am looking to use passport-linkedin in my application. I have successfully implemented same for twitter, facebook and instagram. However with linkedin, I get getting the following 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 code looks like

xports.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 here’s the routing setup

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

Also, I have setup the appropriate endpoints on linkedin as follows;

Authorized Redirect URLs:

    http://testdomain.ngrok.io/oauth/linkedin/callback
    http://localhost:9000/oauth/linkedin/callback
    http://127.0.0.1:9000/oauth/linkedin/callback

Default “Accept” Redirect URL:

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

I tried each of the above but always had the same error. I don’t know what to do next, I’d really appreciate any help. Thanks 😃

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:6
  • Comments:15

github_iconTop GitHub Comments

3reactions
jaredwacommented, Nov 10, 2017

I had this issue and had to use

https://github.com/jaredhanson/passport-google-oauth2

rather than the basic google auth in the docs to make it work. It looks like the original uses an outdated URL.

2reactions
umairjyetoocommented, Aug 6, 2018

Well I was getting the same error but then i used
var GoogleStrategy = require(‘passport-google-oauth’).OAuth2Strategy; instead of .OAuthStrategy … It worked for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to obtain request token passport-google in nodejs ...
I am trying to authenticate user, using google authentication passport-google but it keeps sending InternalOAuthError: Failed to obtain ...
Read more >
InternalOAuthError: Failed to obtain access token 0 #64 - GitHub
6 an error of "InternalOAuthError: Failed to obtain access token 0" was thrown. //jshint esversion:6 require("dotenv").config(); ...
Read more >
InternalOAuthError: Failed to obtain access token - Support
Server shows in the logs: InternalOAuthError: Failed to obtain access token at OAuth2CustomStrategy.OAuth2Strategy.
Read more >
InternalOAuthError: Failed to obtain access token
Hello, My company has recently moved offices, and in the process switched firewalls. The app we've been using was fine before, ...
Read more >
Failed to obtain access token at GoogleStrategy.OAuth...
In this article, we are going to implement (OAuth) login with google in Nest JS. ... InternalOAuthError: Failed to obtain access token
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found