Having trouble logging out with @okta/oidc-middleware

Hi,

I’m using node and Okta’s middleware in order to integrate Okta with my website. I am able to log in just fine, but I’m having trouble logging out. I’m trying to POST to the auto-generated /logout route, but I always get:

“UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘tokens’ of undefined”

I looked into the logout.js code, and saw that it had this line: “const tokens = req.userContext.tokens”, which is why it was considered undefined. I changed it so that it actually got the tokens from the request (by changing it to “req.body.userContext.tokens”), but now I’m getting “Unable to configure ExpressOIDC revokeError - undefined”.

Here is my code:

app.get(’/logout’, (req, res) => {
request({
headers: {
‘content-type’: “application/json”
},
uri: ‘http://localhost:5002/logout’,
json: {“userContext”: req.userContext},
method: ‘POST’
}, function (err, res, body){
})
res.redirect(’/’)
})

How do I fix it so that the user actually logs out? Was anyone else able to implement logout by using the middleware? Thanks!

@brawong Lately I’ve been seeing this too. Did you ever figure it out?

Over 2 years later and over 1000 views and no response. I am also having this issue. Where the devs at?

I didn’t encounter the issue with /logout while running the sample app at GitHub - okta/samples-nodejs-express-4: Express 4 samples. Will publish an artifact that can be co.

If you have the steps to reproduce the issue, please file an issue on GitHub.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.