Skip to content

jschell12/passport-linkedin-oauth2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple Passport strategy for LinkedIn OAuth2.

Install

npm install passport-linkedin-oauth2

Usage

Register the strategy

var LinkedInStrategy = require('passport-linkedin-oauth2').Strategy;

passport.use(new LinkedInStrategy({
    	clientID: LINKEDIN_KEY,
    	clientSecret: LINKEDIN_SECRET,
    	callbackURL: "http://127.0.0.1:3000/auth/linkedin/callback"
  		},
	  function(accessToken, refreshToken, profile, done) {
	    	// asynchronous verification, for effect...
		    process.nextTick(function () {
		      
		      // To keep the example simple, the user's Google profile is returned to
		      // represent the logged-in user.  In a typical application, you would want
		      // to associate the Google account with a user record in your database,
		      // and return that user instead.
		      return done(null, profile);
		    });
	  		}
		));

and then authenticate as:

app.get('/auth/linkedin',
                passport.authenticate('linkedin', { scope: ['r_emailaddress', 'r_basicprofile'],
                                                    state: 'SOME STATE'  }),
		  function(req, res){
		    // The request will be redirected to LinkedIn for authentication, so this
		    // function will not be called.
		  });

the login callback:

app.get('/auth/linkedin/callback', passport.authenticate('linkedin', { 
   successRedirect: '/',
   failureRedirect: '/login' 
}));

See this for details on LinkedIn API.

License

MIT - 2013 - AUTH0

About

Passport strategy for LinkedIn Oauth2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%