[keycloak-user] How to add users in bulk

Stian Thorgersen stian at redhat.com
Mon Dec 29 03:11:05 EST 2014



----- Original Message -----
> From: "Hubert Przybysz" <h.p.przybysz at gmail.com>
> To: "Bill Burke" <bburke at redhat.com>
> Cc: keycloak-user at lists.jboss.org
> Sent: Thursday, 18 December, 2014 10:56:20 AM
> Subject: Re: [keycloak-user] How to add users in bulk
> 
> Thanks both for quick responses.
> 
> I have a large number of users I want to migrate from another system to
> keycloak. I could, as Bill suggests, write a piece of code that reads the
> users from the existing system and adds them to keycloak using the admin
> REST API. While not difficult, it takes a bit of work/time.
> 
> I looked earlier at export-import but understood that in order to import
> users I had to first export them, meaning that they must have been already
> provisioned in keycloak, correct? If that's not true, perhaps I can add my
> users to the import file in some way ?

Just double checked the approach I suggested. I thought we had made it possible to import users into an existing realm, but that's not the case. You have to create the whole realm. It's still possible to do it this way, first create the realm and add an example user. Stop the server and run it again with:

  bin/standalone.sh -Dkeycloak.migration.action=export -Dkeycloak.migration.provider=dir -Dkeycloak.migration.realmName=<realm name> -Dkeycloak.migration.dir=<dir name>

* Replace <realm name> and <dir name>

In <dir name> you should then get a few json files. You can then update <realm name>-users-0.json to add the users you want to import.

As Bill points out the admin client could be a good alternative approach. We also have a Java client that makes it simpler to use. Have a look at the admin-client example.

> 
> On Thu, Dec 18, 2014 at 5:15 AM, Bill Burke < bburke at redhat.com > wrote:
> 
> YOu can also use the admin REST API.
> 
> On 12/17/2014 8:01 AM, Stian Thorgersen wrote:
> > You can import users from json files, see
> > http://docs.jboss.org/keycloak/docs/1.1.0.Beta2/userguide/html/export-import.html
> > 
> > ----- Original Message -----
> >> From: "Hubert Przybysz" < h.p.przybysz at gmail.com >
> >> To: keycloak-user at lists.jboss.org
> >> Sent: Sunday, 14 December, 2014 5:36:49 PM
> >> Subject: [keycloak-user] How to add users in bulk
> >> 
> >> Hi,
> >> Is there an easy way of adding a large number users to a realm, where
> >> usernames and initial passwords follow a certain pattern?
> >> Best regards / Hubert.
> >> 
> >> _______________________________________________
> >> keycloak-user mailing list
> >> keycloak-user at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/keycloak-user
> > _______________________________________________
> > keycloak-user mailing list
> > keycloak-user at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/keycloak-user
> > 
> 
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
> 
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user


More information about the keycloak-user mailing list