'Sync User Keycloack with User spring boot app
Hello I'm on a spring boot application with a keycloak authentication server and I would like to save the users on the spring database does anyone have a track to help me thank you in advance
Solution 1:[1]
You can listen when a user is created successfully using EventiListener spi
Code sample that is only executed only when the transaction is successful:
public class MyEventListenerProvider implements EventListenerProvider {
private EventListenerTransaction tx = new EventListenerTransaction(this::processAdminEvent,this::processEvent);
@Override
public void onEvent(Event event) {
tx.addEvent(event);
}
@Override
public void onEvent(AdminEvent adminEvent, boolean includeRepresentation) {
tx.addAdminEvent(adminEvent, includeRepresentation);
}
private void processAdminEvent(AdminEvent adminEvent, boolean includeRepresentation) {
// Do whatever you want with the admin event
}
private void processEvent(Event event) {
// Do whatever you want with the event
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Paul |
