auth0 / passport-linkedin-oauth2

Passport Strategy for LinkedIn OAuth 2.0
MIT License
119 stars 106 forks source link

Cannot authenticate #11

Closed jalleyne closed 9 years ago

jalleyne commented 10 years ago

Hi, Im trying to use your module and i am running into issues with the response from LinkedIn.

/authenticate/__cb__/linkedin?error=invalid_request&error_description=You+need+to+pass+the+%22state%22+parameter

this is what i get returned to my callback. from what i can tell your api doesnt send the state parameter and i can't see anywhere to add this using your functions.

looking into your code i see a method Strategy.prototype.authorizationParams but it is never called in your code.

Is there something im missing or is this parameter recently enforced as required by linkedin? thanks

alexanderlperez commented 10 years ago

I might be having the same issue as yourself. I'm running a LocomotiveJS app with Node, and authenticating with the LinkedInStrategy responds with a callback url of the form:

http://domain.com/authenticate/linkedin/callback?code=LONG-STRING-OF-CHARACTERS&state=some+state

The current configuration is as follows:

// Locomotive routes                                                                                                                                                                                                                      
this.match('authenticate/linkedin/', passport.authorize('linkedin', { state: 'some state' });                                                                                                                                                                                                                                                                                                                                                                                                                                                              
this.match('authenticate/linkedin/callback', passport.authorize('linkedin', {                                                                                                                                                                                                      
            successRedirect: 'http://reddit.com',                                                                                                                                                                                             
            failureRedirect: 'http://cnn.com'                                                                                                                                                                                                 
    });  

var LinkedInStrategy = require('passport-linkedin-oauth2').Strategy;
passport.use(new LinkedInStrategy({                                                                                                                                                                                                           
    clientID: process.env.LINKEDIN_API_KEY,                                                                                                                                                                                                   
    clientSecret: process.env.LINKEDIN_SECRET_KEY,                                                                                                                                                                                            
    callbackURL: process.env.LINKEDIN_CALLBACK,                                                                                                                                                                                               
    scope: ['r_emailaddress', 'r_basicprofile'],                                                                                                                                                                                              
    passReqToCallback: true                                                                                                                                                                                                                   
}, function(req, accessToken, refreshToken, profile, done) {                                                                                                                                                                                  
    console.log("does get called?");                                                                                                                                                                                                                                                                                                                                                                                                  
        return done(null, {});                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
})); 

All this results in a 404.

jfromaniello commented 10 years ago

@alexanderlperez I'm not familiar with locomitve, have a look to the example directory in this repository.

dstroot commented 9 years ago

See pull request #19 - addresses this exact issue.