This is my first project with both passport and Okta in a Nodejs app. I can get the Okta login page, successfully login to Okta, and get redirected to the callback url with a code. This works perfectly.
However, I am having a problem getting the user profile. The call to passport.authenticate in the callback hangs. There are no errors reported or in the log.
I have looked at multiple examples and tried many variations, but I do not see what I am doing wrong. Any idea?
Code segment:
passport.use('oidc', new Strategy({
issuer: process.env.ISSUER_URL,
authorizationURL: process.env.AUTH_URL,
tokenURL: process.env.TOKEN_URL,
userInfoURL: process.env.USER_URL,
clientID: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
callbackURL: process.env.CALLBACK_URL,
scope: 'openid profile'
}, (issuer, profile, done) => {
return done(null, profile);
}));
passport.serializeUser((user, done) => {
done(null, user);
});
passport.deserializeUser((obj, done) => {
done(null, obj);
});
app.post('/oktalogin', passport.authenticate('oidc'));
app.use('/authorization-code/callback', function(req,res) {
passport.authenticate('oidc', { failureRedirect: '/autherror' }),
(req, res) => { res.redirect('/profile') };
});
app.use('/profile', (req, res) => {
res.render('profile', { USER: req.user });
});
app.use('/autherror', (req,res) => {
res.render('error',{ MSG: "AUTH ERROR" });
});