Building OAuth Strategies with passport.js Chapter 7
// Handle linkedin login
}));
};
In the preceding code, the first line imports the LinkedIn Strategy. The configuration takes
the following three parameters: clientID, clientSecret, and a callback URL. The
clientID and clientSecret are the App ID and App Secret of the LinkedIn
application we just created, respectively.
Let's add those secrets to our config file. In config/Config.js, add the Facebook
Client ID and Facebook Client Secret:
module.exports = {
DB: 'mongodb://localhost/movie_rating_app',
SECRET: 'movieratingappsecretkey',
FACEBOOK_APP_ID: <facebook_client_id>,
FACEBOOK_APP_SECRET: <facebook_client_secret>,
TWITTER_APP_ID: <twitter_consumer_id>,
TWITTER_APP_SECRET: <twitter_consumer_secret>,
GOOGLE_APP_ID: <google_consumer_id>,
GOOGLE_APP_SECRET: <google_consumer_secret>,
LINKEDIN_APP_ID: <linkedin_consumer_id>,
LINKEDIN_APP_SECRET: <linkedin_consumer_secret>
}
The callbackURL is the URL that you want to route your application to after the successful
transaction with LinkedIn.
The callbackURL that we have defined in the preceding code is
http://127.0.0.1:8081/login/linkedin/return, which we have to define. The
configuration is followed by a function that takes the following four parameters:
accessToken
refreshToken
profile
cb (callback)
Upon successful request, our application will get redirected to the profile page, which we
are yet to define.