[keycloak-user] How to create a realm using the admin client

Michael Yoder myoder at cloudera.com
Wed Mar 7 18:05:27 EST 2018


Thanks for the help!  I dug through your code (which helped), and I'll just
go ahead and use httpclient to send the POSTs myself.  I really do want to
do this inside a java program and not deal with a fork/exec of kcadm.sh.

Regards,
-Mike


On Thu, Feb 22, 2018 at 7:19 AM, Marko Strukelj <mstrukel at redhat.com> wrote:

> And of course if the realm does not yet exist in the target server you
> have to create it first:
>
> $ kcadm.sh create realms -s realm=demorealm -s enabled=true
>
> On Thu, Feb 22, 2018 at 4:12 PM, Marko Strukelj <mstrukel at redhat.com>
> wrote:
>
>> You can achieve that by using Admin CLI (for example - if you have
>> exported a demorealm.json using boot time export, you can import it into a
>> live server as follows):
>>
>> $ kcadm.sh create -r demorealm partialImport -s ifResourceExists=FAIL -o
>> -f - < demorealm.json
>>
>>
>> Basically you POST the demorealm.json as a body to
>> http://localhost:8080/auth/admin/realms/demorealm/partialImport
>>
>>
>> And you add additional attribute into realm JSON body
>> ("ifResourceExists": "FAIL").
>>
>>
>> If you only want to add extra things into existing realm, you can use
>> "SKIP". And there is also "OVERWRITE" which you probably want to avoid.
>>
>> On Wed, Feb 21, 2018 at 12:58 AM, Michael Yoder <myoder at cloudera.com>
>> wrote:
>>
>>> I've got the json from a realm export. Now I'd like to re-create that
>>> realm
>>> using the keycloak-admin-client library.  Is there any sample code out
>>> there?  Hints?
>>> I've found
>>>
>>> http://www.keycloak.org/docs/3.4/server_development/#admin-rest-api
>>>
>>> and
>>>
>>> http://www.keycloak.org/docs-api/3.4/javadocs/
>>>
>>> and even
>>>
>>> https://github.com/keycloak/keycloak/blob/master/integration
>>> /admin-client/src/main/java/org/keycloak/admin/client/resour
>>> ce/RealmResource.java
>>>
>>> I feel like I've got parts of it, but I don't know how to put the pieces
>>> together. Any help would be appreciated.
>>>
>>> Thanks,
>>> -Mike Yoder
>>> _______________________________________________
>>> 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