[keycloak-user] Batch import of accounts into Keycloak
Eugene Chow
eugene.chow.ct at gmail.com
Thu May 7 23:29:39 EDT 2015
Thanks Marek for the detailed explanation! I’ll give it a shot.
> Hi,
>
> you first need to enable "Direct access grant" for the master realm.
> Then retrieve the token via direct access grant request for the master
> realm for example with "security-admin-console" application. You can see
> some example in the docs on how to do it:
> http://docs.jboss.org/keycloak/docs/1.2.0.CR1/userguide/html/direct-access-grants.html
> . Use username/password of admin user in the endpoint (admin/admin by
> default).
>
> Note that we have some more examples showing direct access grant (as
> pointed on that page in the docs) and especially that admin-client
> handles this for you, which is one of his big advantages.
>
> Then REST endpoint for adding user is here:
> http://docs.jboss.org/keycloak/docs/1.2.0.CR1/rest-api/admin/realms/%7Brealm%7D/users/index.html#POST
> . For change password, you need to use endpoint for "reset-password" and
> then use another endpoint for removing required action from the user (as
> reseting password will add this required action automatically).
>
> For more inspiration, you can also use keycloak admin console and use
> some tool (For example Firebug in FF) to see which REST endpoints is
> admin console itself using. Note that admin console is angular
> application, which invokes all these admin REST endpoints under the hood.
>
> Marek
>
> On 6.5.2015 17:26, Eugene Chow wrote:
>> Hi Marek,
>>
>> Thanks for the link. Looks like it came up shortly before I posted.
>>
>> I would like to first try the REST API as I can quickly whip up a BASH
>> script to perform the batch import. In 1.2.0.CR1's REST API
>> documentation, there doesn't seem to be an option to login as admin and
>> get the token.
>>
>> Could you point out which URL I should call to login via curl on the CLI?
>>
>> Thanks!
>>
>> On 6/5/2015 10:33 PM, Marek Posolda wrote:
>>> Hi,
>>>
>>> we have some admin REST API documented and the operations you mentioned
>>> should be available there:
>>> http://docs.jboss.org/keycloak/docs/1.2.0.CR1/rest-api/overview-index.html
>>>
>>> Maybe easiest solution for you would be to use our admin-client, which
>>> allows to easily invoke REST endpoints as java methods and handles
>>> obtain the accessToken for admin authentication too. If your
>>> command-line has Java available, you can just run simple Java program,
>>> which will use admin-client to invoke REST endpoints. The example for
>>> admin client is here:
>>> https://github.com/keycloak/keycloak/tree/master/examples/admin-client
>>>
>>> Marek
>>>
>>>
>>> On 5.5.2015 17:30, Eugene Chow wrote:
>>>> Hi,
>>>>
>>>> First of all, a big thank you to the developers for an SSO that's simple
>>>> to use and a beautiful interface to boot.
>>>>
>>>> I'm running Keycloak for an app in development. For UAT purposes, I need
>>>> to batch import accounts from a CSV file via the command-line. I'm
>>>> looking for the REST API to login as admin, get token, create new
>>>> account, update new acct's password, and then logout. I haven't found
>>>> any documentation on this.
>>>>
>>>> If the REST API is not equipped for this purpose, what would be the
>>>> correct method to bulk import users?
>>>>
>>>> Thanks!
>> _______________________________________________
>> 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