Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4802

How can I update keycloak's user details programmatically (java), without using rest admin api?

$
0
0

I want to update the user detail. e.g. I created user(k1) in "demo" realm from keycloak admin console. I have one java client and I want to update the user(k1) details like. Change Email address of user k1.

I did using Admin client(Rest API) as below.

public void updateEmail(final String newEmailAddress) {    try {        final AccessToken accessToken = getToken();        Keycloak keycloak = KeycloakBuilder.builder().serverUrl(this.getDeployment().getAuthServerBaseUrl())                .realm(this.getDeployment().getRealm()).username("k1").password("123").clientId(ADMIN_CLIENT)                .resteasyClient(new ResteasyClientBuilder().connectionPoolSize(10).build()).build();        UserResource userResource = keycloak.realm(this.getDeployment().getRealm()).users()                .get(accessToken.getSubject());        UserRepresentation user = userResource.toRepresentation();        user.setEmail(newEmailAddress);        userResource.update(user);    } catch (Exception exception) {        exception.printStackTrace();    }}

But I want do the same without using Admin client.


Viewing all articles
Browse latest Browse all 4802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>