I would like to use the REST API from Keycloak to reset a password from a user. I have two realms:
- master
- myapp
In "myapp" I have all my users. "master" was only there from the installation. I´m currently struggeling which settings do I need in Keycloak. Which can I use to reset the password / use the API?
If I´m using this I´m getting a error, the user "[email protected]" will not found. I think I need to use realm = myapp ?
String serverUrl = "http://localhost:9009/auth";
String realm = "master";
String adminUsername = "admin";
String adminPassword = "admin";
Keycloak keycloak = Keycloak.getInstance(serverUrl, // Keycloak-Server-URL
realm, // Realm
clientId, // Administrator-Benutzername
clientSecret, // Administrator-Passwort
"admin-cli"); // Client-ID des Keycloak-Admin-Clients
UsersResource usersResource = keycloak.realm(realm).users();
List<UserRepresentation> list = usersResource.searchByEmail("[email protected]", true);
If I change it to
String realm = "myapp";
I got this error message:
Exception in thread "main" jakarta.ws.rs.ProcessingException: jakarta.ws.rs.NotAuthorizedException: HTTP 401 Unauthorized
So I need help:
- How do I setup Keycloak. Which user, which password, which credential settings etc. for using it with my REST API.
Thank you for help