I have 2 different applications: say Application1 and Application2.
I have integrated Application2 with keycloak and I am able to login to this application using Keycloak's login page.
Now what I want is, if I login to my Application1 (without keycloak), I should be able to call some API of keycloak to login to application2 (without rendering keycloak's login page).
It is feasible? If yes, how?
Any help will be highly appreciated.
Thanks
You are effectively asking your users to trust that Application1 will manage their keycloak credentials securely. This is not recommended because
But if you control and can trust Application1 and need to do this due to legacy or other reasons then you can enable the Resource Owner Credentials Flow called "Direct Access" on the Keycloak Client Definition, and then POST the user's credentials as a
form-urlencoded
data type toThe paramaters will be
The response will be a valid JWT object or a 4xx error if the credentials are invalid.
YES- You can login to the Application-1 with out using keycloak login interface.
Various client adapters are available for achieving this. here you didn't mentioned your application frame work.
To know more about the keyclaok client adapters : click here
For example if you are choosing Node.js adapter then you can follow the link : node.js adapter
keycloak implementation with node.js adapter, details about the REST api's and token validation mechanism are well explained in this link click for example
If I got your question correctly you are trying to call a bearer-only service through another application that's already logged in, you also didn't mention if you are using Spring Boot or another framework like it, so I'll suppose that you are using the Spring Boot for your server-side application.
The following example reflects into a simple call of an authenticated API to another one, both using Spring Boot:
By that way is possible to send the actual valid token generated by your origin service to another service.