This is below simple code I am trying to create Keycloak user in the master
Realm.
But I am getting Bad request
in return and below warning in Keycloak
:
10:27:58,256 WARN [org.keycloak.events] (default task-111) type=LOGIN_ERROR, realmId=master, clientId=security-admin-console, userId=null, ipAddress=127.0.0.1, error=not_allowed, auth_method=oauth_credentials, grant_type=password, client_auth_method=client-secret
Keycloak kc = Keycloak.getInstance("http://localhost:8080/auth", "master", "admin", "password","security-admin-console");
CredentialRepresentation credential = new CredentialRepresentation();
credential.setType(CredentialRepresentation.PASSWORD);
credential.setValue(password);
credential.setTemporary(false);
UserRepresentation user = new UserRepresentation();
user.setUsername(username);
user.setFirstName("Test");
user.setLastName("User");
user.setEnabled(true);
user.setCredentials(Arrays.asList(credential));
kc.realm("master").users().create(user);