I am using below code for keycloak inside my NodeJS application but once I use keycloak.protect() inside function it is not working.
app.get('/testPage', testFunction);
function testFunction(req, res) {
keycloak.protect(), function (req, res) {
res.render('index', {
result: JSON.stringify(JSON.parse(req.session['keycloak-token']), null, 4),
event: '1. Authentication\n2. Login'
});
}
}
URL: http://localhost:port/testPage Not working
When I used app.get('/loginPage',
keycloak.protect(), function (req, res) {}); it is working fine. Please let me know what is the issue?
How I can use inside the function this keycloak.protect() method.
URL: http://localhost:port/testPage working
app.get('/loginPage',
keycloak.protect(), function (req, res) {
res.render('index', {
result: JSON.stringify(JSON.parse(req.session['keycloak-token']), null, 4),
event: '1. Authentication\n2. Login'
});
}
);