Communication between two micro services - keycloak clients

 ̄綄美尐妖づ 提交于 2020-01-06 14:29:18

问题


I have two services registered as two keycloak clients in the same realm. Access type of both the clients is set to public in keycloak client settings.

Both the services works fine when we try to login via Keycloak.

After login to first(service-1) user does some operation, for which I need to make a REST call to (service-2). Now If I try to do a REST call from one service to other, It redirects to HTML and returns some HTML response instead of actual response.

What is the Way I can make calls between these two services.


回答1:


To communicate to an api protected via keycloak you need to provide authorization. For that all you need to do is pass the access token in the authorization header.

To get this token you can make a login call, get the access token and pass that along or you can make use of the token passed to access to first service itself.




回答2:


No it is not possible yet because this issue https://issues.jboss.org/plugins/servlet/mobile#issue/KEYCLOAK-6073. In summary you cannot use the token generated by the login web page in the backed calls unless you use the same keycloak URL in both cases.



来源:https://stackoverflow.com/questions/51835334/communication-between-two-micro-services-keycloak-clients

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!