<div dir="ltr">Hi,<div> I&#39;m creating users programmatically from my java code,but the users credential and roles are note &quot;persisted&quot; (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(&quot;123&quot;);                                                               </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(&quot;guest&quot;));                                          <br></i></div><div><br></div><div>Cordially </div></div>