Mowso
Mowso

Reputation: 147

Accessing Keycloak endpoints

Context

A NestJS back-end project at their beginnings with no e2e tests

As OpenID Connect Node.js adapters are deprecated, I am implementing my own Keycloak service in the NestJs app

Keycloak & mySQL database both on a Docker instance

Keycloak act as middleware protecting routes and allowing users to login

Keycloak has a dedicated realm I configured with a set of clients and users (barely no custom roles or group for now)

How I use Insomnia to get token from Keycloak and then get access to routes in my app

my keycloak config

my keycloak config

It is a necessity for me and my team to test endpoints via Postman like software, we chose Insomnia

PROBLEM

We have trouble accessing endpoints with token through insomnia and issues debugging due to the lack of info returned by Keycloak

Insomnia screenshot

keycloak-1  | 2024-03-13 09:37:16,675 WARN  [org.keycloak.events] (executor-thread-1) type="USER_INFO_REQUEST_ERROR", realmId="55542514-fc71-4e4e-be3e-42af869de2a7", clientId="null", userId="null", ipAddress="172.18.0.1", error="access_denied", auth_method="validate_access_token"

EDIT: Try via CLI

curl http://localhost:8080/realms/myapp/protocol/openid-connect/userinfo -H "Authorization: Bearer <mytoken>"

It is throwing the same access denied response

Upvotes: 0

Views: 208

Answers (0)

Related Questions