<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">You need to use separate endpoints for
update credentials and separate endpoint for update roles. For
example see our testsuite
<a class="moz-txt-link-freetext" href="https://github.com/keycloak/keycloak/blob/master/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java">https://github.com/keycloak/keycloak/blob/master/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java</a><br>
<br>
Marek<br>
<br>
On 31/08/16 15:26, yassine yas wrote:<br>
</div>
<blockquote
cite="mid:CAMW2P2n82aha+fcoxKj0O3VbKArHmEaSwU-9O4Vz4c3ntDHAqw@mail.gmail.com"
type="cite">
<div dir="ltr">Hi,
<div> I'm creating users programmatically from my java code,but
the users credential and roles are note "persisted" (I think),
when the user try to authenticate he get <b>Invalid username
or password (</b>even if he is visible in the admin
console), If I define (from the admin console) a passe Word
for the user and use it he can access his account, but here
come the 2 problem, even if I give him the right (role) to use
a resource he gets forbidden.</div>
<div>here is the code that I use to define users credential and
role :</div>
<div><br>
</div>
<div>
<div><span style="background-color:rgb(238,238,238)"> <i>
CredentialRepresentation credential = new
CredentialRepresentation();</i></span></div>
<div><i style="background-color:rgb(238,238,238)">
credential.setType(CredentialRepresentation.PASSWORD);
</i></div>
<div><i style="background-color:rgb(238,238,238)">
credential.setValue("123");
</i></div>
</div>
<div><i style="background-color:rgb(238,238,238)">
user.setCredentials(Arrays.asList(credential));
<br>
</i></div>
<div><i style="background-color:rgb(238,238,238)">
user.setRealmRoles(Arrays.asList("guest"));
<br>
</i></div>
<div><br>
</div>
<div>Cordially </div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
keycloak-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/keycloak-user">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>
</blockquote>
<br>
</body>
</html>