How to get Okta token in express 4.0 api application

Hi Team,

We have a node express application. We have created an end point /login which accepts user credential and send then to Okta for verification. We are able to get user authentication using user credentials. But problem arises when we try to fetch token in next step. authClient.token.getWithoutPrompt() method call is timing out. We have already configured our api endpoint as callback url. Not sure what else I need to do.

Any help on this is appreciated. Attaching below the code sample

var config = {
url: “https://mmc.oktapreview.com”,
// Optional config
issuer: “https://mmc.oktapreview.com/oauth2/default”,
clientId: “0oafqiomgcXMEcaRK0h7”,
redirectUri: “http://localhost:8100/implicit/callback”,
scope: “openid profile email address phone offline_access WarrenTest”
};

var authClient = new OktaAuth(config);
authClient
.signIn({
username: username,
password: password
})
.then(function(transaction) {
if (transaction.status === “SUCCESS”) {
let scope = “openid profile email address phone offline_access WarrenTest”;
//authClient.session.setCookieAndRedirect(transaction.sessionToken); // Sets a cookie on redirect
authClient.token
.getWithoutPrompt({
nonce: ‘51GePTswrm’,
responseType: [“id_token”, “token”], // or array of types
sessionToken: transaction.sessionToken, // optional if the user has an existing Okta session
scopes: scope.split(" ")
})
.then(tokens => {
console.log(tokens);
let tokens = {
id_token: tokens[0].idToken,
access_token: tokens[1].accessToken,
};
//console.log(tokens);
console.log(transaction.status);
res.status(200).send(“Success”);
})
.catch(function(err) {
console.log(err);
res.status(500).send(“FAILURE”);
});
console.log(transaction.status);
} else {
throw “We cannot handle the " + transaction.status + " status”;
}
})
.fail(function(err) {
console.error(err);
res.status(500).send(“FAILURE”);
});

Thanks,
Manish Kumar