I have been trying to implement linked OAuth with passport.js, but I keep getting the message the application is disabled

I have rechecked the code multiple times but can’t find anything wrong with the implementation. I have also tried troubleshooting by logging messages, but there are no errors. The passport.authenticate is not being executed because the only thing on the console is the this is where authentication will be done message.
This is what the LinkedIn route looks like:
app.get('/api/auth/linkedin', async (req: Request, res: Response, next: NextFunction) => {
console.log('this is where authentication will be done');
return passport.authenticate('linkedin', {
scope: ['r_emailaddress', 'r_liteprofile'],
state: JSON.stringify(req.query),
})(req, res, next);
});
This is the passport strategy implementation:
passport.use(
new LinkedInStrategy.Strategy(
{
clientID: process.env.LINKED_IN_CLIENT_ID,
clientSecret: process.env.LINKED_IN_CLIENT_SECRET,
callbackURL: process.env.LINKED_IN_CALL_BACK_URL,
scope: ['r_emailaddress', 'r_liteprofile'],
},
async (accessToken, refreshToken, profile: any, done) => {
console.log('linkedin passport callback function fired');
const email = profile.emails[0]?.value;
const displayName = profile.displayName;
const familyName = profile.name?.familyName;
const givenName = profile.name?.givenName;
const fullName = displayName || givenName + familyName || familyName;
const photo_url = profile.photos?.[0]?.value || '';
const user: any = await userService.confirmSocialMediaAccount({
email,
photo_url,
source: 'linkedin',
fullName,
modificationNotes: [
{
modifiedOn: new Date(Date.now()),
modifiedBy: null,
modificationNote: 'New user created',
},
],
});
done(null, user);
}
)
);
And this is what the call-back route looks like:
app.get('/api/auth/linkedin/callback', (req: Request, res: Response, next: NextFunction) => {
console.log('Handling LinkedIn callback');
passport.authenticate('linkedin', { failureRedirect: '/login' }, (err, user) => {
if (err) {
console.error('Authentication Error:', err);
return next(err);
}
if (!user) {
return res.redirect('/login');
}
console.log('User authenticated:', user);
})(req, res, next);
});
