Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InternalOAuthError - failed to obtain request token #19

Open
elimence opened this issue Jun 3, 2015 · 15 comments
Open

InternalOAuthError - failed to obtain request token #19

elimence opened this issue Jun 3, 2015 · 15 comments

Comments

@elimence
Copy link

elimence commented Jun 3, 2015

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 :)

@jackcohen5
Copy link

Also having this issue, any luck?

@elimence
Copy link
Author

elimence commented Jul 3, 2015

No luck, but recheck your key's, I've had trouble with those in other cases.

@jackcohen5
Copy link

Try running npm update and bower update

After running both of those, I got it working again

@elimence
Copy link
Author

elimence commented Jul 3, 2015

Ok, will give that a shot, and thanks :)

@gauravbansal74
Copy link

Hi I am getting same error. Please help me to resolve this.

TIA.
Gaurav

@jackcohen5
Copy link

Did you try running npm update and bower update?

@gauravbansal74
Copy link

yes .. I tried everything... Now I am using "passport-linkedin-oauth2" NPM. Its working smoothly for me.

Thank you for your quick reply.

  • Gaurav

@arung-ideas2it
Copy link

Hey guys ! I am using Mean IO where they followed OAuth 1. x strategy for LinkedIn....Could you help to overcome this issue

@a455bcd9
Copy link

a455bcd9 commented Aug 29, 2016

@elimence It seems that you used OAuth2, this package is a strategy for authenticating with LinkedIn using the OAuth 1.0a API. Try using https://github.com/auth0/passport-linkedin-oauth2 instead, it should work.

@askucher
Copy link

Dame same issue.

@MyNameIsAlaa
Copy link

same issue here! any solution?

@kmokrzycki
Copy link

Initially I had very same issue and my problem was the scope.I was asking for non-existing scope r_fullprofile that is not available any more, and funny enough this was failing only occasionally not all the time, there must be some inconsistency at LinkedIn side.

Try to limit you scope just to a single known value.

@jaredwa
Copy link

jaredwa commented 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.

@umairjyetoo
Copy link

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

@shibly97
Copy link

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

this worked for me as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests