Keycloak spring security, cross realm: Didn't find publicKey for kid

Hey,

we are implementing keyloak’s spring security (keycloak adapter)…
our architecture consists of multiple backend microservices…

Everything works as long as we are calling services that are configured in keycloak in the same realm.
So also the security service1->backendservic2 works, it uses same token (through KeycloakRestTemplate).

But some backendservices are in different realm, and in that case we get “Didn’t find publicKey for kid” Because the tokenValidator does not have the publickey id in its store (the id is from realm X but it is validate in realm Y).

What whould be the solution, try to add same rsa key in realm Y ?? But how to optain private rsa key then ? Or are there other solutions ?

Did you find the solution for this issue ? Currently I have been struggling for this