I have used keycloak.middleware() and keycloak.protect() for my api after redirect to keycloak sign in and successful sign in
I get this error for calling the api
{“error”:“cannot exchange code for grant in bearer-only mode”}
You need to configure and use the authentication token flow, not the bearer token flow both in keycloak ( realm client settings) and in the client itself.