Building OAuth Strategies with passport.js Chapter 7
The preceding code will add a LOGIN WITH LINKEDIN button:
Adding configurations for LinkedIn app
Let's configure the LinkedIn strategy just as we did for all the other strategies. We will
create a separate file to handle LinkedIn login so that the code is simple. Let's create a file
called linkedin.js inside the controllers folder and add the following contents to it:
const User = require('../models/User.js');
const passport = require('passport');
const config = require('./../config/Config');
const Strategy = require('passport-linkedin').Strategy;
module.exports.controller = (app) => {
// linkedin strategy
passport.use(new Strategy({
consumerKey: config.LINKEDIN_APP_ID,
consumerSecret: config.LINKEDIN_APP_SECRET,
callbackURL: '/login/linkedin/return',
profileFields: ['id', 'first-name', 'last-name', 'email-address']
},
(accessToken, refreshToken, profile, cb) => {