Cannot exchange code for grant in bearer-only mode

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”}

Kindly help
thanks in advance

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.

1 Like

Thanks I have found the solution for the same
I was not passing headers properly