I am currently building a NodeJS web application (I am currently hosting this locally, but will use AWS later) but am having trouble with integrating Okta. I have attempted to use the OIDC-Okta middleware with a NodeJS app I have created. Not sure if this would be an issue, but I created an application on an organizational OKTA domain (not on the okta devs platform) and made my login redirect URI http://localhost:3000/authorization-code/callback.
I followed most of the code on the OKTA github to try to run my nodeJS server: https://github.com/okta/okta-oidc-js/tree/master/packages/oidc-middleware#upgrading
However, when running the code my server does not connect. When I comment out the oidc on or don’t use the OIDC framework, my server is loaded. I believe this might be an issue due to my OIDC config, but I have no clue because I only get a timeout error from my error messaging. How could I debug and make sure my connection/config is valid without error messaging?
If you’d like an overview of the relevant snippet of code here it is:
var express = require('express');
var app = express();
var port = 3000;
app.set('view engine', 'ejs');
const options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
const session = require("express-session");
const { ExpressOIDC } = require("@okta/oidc-middleware");
app.use(session({
secret: Files.generateRandomString(25),
resave: true,
saveUninitialized: false
}));
let oidc = new ExpressOIDC({
issuer: "https://{mydomain}/oauth2/default",
client_id: {myclientID},
client_secret: {mysecrettoken},
appBaseUrl: "http://localhost:3000",
routes:{
loginCallback: {path: "http://localhost:3000/authorization-code/callback"},
logoutCallback: {path: "http://localhost:3000/"}
},
maxClockSkew: 240,
timeout:10000,
});
app.use(oidc.router);
oidc.on('ready', () => {
app.listen(port, function(){
console.log('Server started at '+ new Date()+', on port ' + port+'!');
});
});
oidc.on('error', err => {
console.log("an error occured" + err);
});