I just took the demo code from this Github
So i change the keycloak-config.json
var keycloakConfig ={
clientId: 'my-api',
bearerOnly: true,
serverUrl: 'https://<IPADDRESS>:8443/auth/',
realm: 'myrealm',
credentials: {
secret: '99e71ca7-f25b-40b5-87ed-0af2656b52ac'
}
};
Now to access the api endpoint first i will generate the token

With the help of above token i am trying to access secure API

But it will fail with the error
403: Access Denied
Here is code
router.get('/user', keycloak.protect(), function(req, res){
res.send("Hello User");
});
Even this also giving same
router.get('/user', keycloak.protect('user'), function(req, res){
res.send("Hello User");
});
I followed this link for this demo code