<div dir="ltr">That's better advice ;)<div><br></div><div>I miss-read the email and thought the problem was the user couldn't login afterwards</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 January 2016 at 10:08, Juraci Paixão Kröhling <span dir="ltr"><<a href="mailto:juraci@kroehling.de" target="_blank">juraci@kroehling.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Make sure to use the Constants.ADMIN_CLI_CLIENT_ID (admin-cli) as the<br>
client, instead of Constants.ADMIN_CONSOLE_CLIENT_ID<br>
(security-admin-console). The second has direct grant disabled by default.<br>
<br>
Additionally, make sure that the admin account already had its password<br>
changed.<br>
<br>
- Juca.<br>
<span class=""><br>
On 12.01.2016 09:04, Stian Thorgersen wrote:<br>
> You need a separate request to set the user credentials, same goes with<br>
> role mappings. Take a look at:<br>
><br>
> <a href="https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/UserTest.java#L595" rel="noreferrer" target="_blank">https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/UserTest.java#L595</a><br>
><br>
> On 12 January 2016 at 02:08, Dirk Franssen <<a href="mailto:dirk.franssen@gmail.com">dirk.franssen@gmail.com</a><br>
</span><div><div class="h5">> <mailto:<a href="mailto:dirk.franssen@gmail.com">dirk.franssen@gmail.com</a>>> wrote:<br>
><br>
> Hi,<br>
><br>
> I have a standard keycloak 1.7.0-Final and a separate jax-rs service<br>
> (both in docker) to create a simple test-user programatically with<br>
> hardcoded params:<br>
><br>
> @Path("users")<br>
> @Stateless<br>
> public class UsersResource {<br>
><br>
> @POST<br>
> public Response createTestUser() {<br>
> Keycloak kc = Keycloak.getInstance(<br>
> "<a href="http://192.168.99.100:8180/auth" rel="noreferrer" target="_blank">http://192.168.99.100:8180/auth</a>",<br>
> "master",<br>
> "admin", "password",<br>
> "security-admin-console");<br>
><br>
> CredentialRepresentation credential = new<br>
> CredentialRepresentation();<br>
> credential.setType(CredentialRepresentation.PASSWORD);<br>
> credential.setValue("test123");<br>
> credential.setTemporary(false); /<br>
> UserRepresentation user = new UserRepresentation();<br>
> user.setUsername("testuser");<br>
> user.setFirstName("Test");<br>
> user.setLastName("User");<br>
> user.setCredentials(Arrays.asList(credential));<br>
> user.setEnabled(true);<br>
> user.setRealmRoles(Arrays.asList("admin"));<br>
> Response result = kc.realm("master").users().create(user);<br>
> return result;<br>
> }<br>
> }<br>
><br>
> But calling the JAX-RS endpoint returns in a delegated 400 Bad<br>
> request. The KC log states only:<br>
><br>
> 00:40:23,436 WARN [org.keycloak.events] (default task-9)<br>
> type=LOGIN_ERROR, realmId=master, clientId=security-admin-console,<br>
> userId=null, ipAddress=172.17.0.1, error=not_allowed,<br>
> grant_type=password, auth_method=oauth_credentials,<br>
> client_auth_method=client-secret<br>
><br>
> Any ideas?<br>
><br>
> Kind regards,<br>
><br>
> Dirk<br>
><br>
><br>
> _______________________________________________<br>
> keycloak-user mailing list<br>
</div></div>> <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a> <mailto:<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a>><br>
> <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
<div class="HOEnZb"><div class="h5">><br>
><br>
><br>
><br>
> _______________________________________________<br>
> keycloak-user mailing list<br>
> <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
><br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</div></div></blockquote></div><br></div>