<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"DejaVu Sans Mono";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Courier New \;color\:black";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Thanks for your reply.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">My problem was that I have used setId instead of setClientId.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:windowtext">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:windowtext"> Marek Posolda [mailto:mposolda@redhat.com]
<br>
<b>Sent:</b> Thursday, May 26, 2016 4:16 PM<br>
<b>To:</b> Haim Vana &lt;haimv@perfectomobile.com&gt;; keycloak-user@lists.jboss.org<br>
<b>Subject:</b> Re: [keycloak-user] How to create the same client (same id) for multiple realms programmatically<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">You can use for example:<o:p></o:p></p>
<pre style="background:white"><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif">RealmResource realm1 = </span><b><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif;color:#660E7A">adminClient</span></b><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif">.realms().realm(</span><b><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif;color:green">&quot;realm1&quot;</span></b><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif">);<o:p></o:p></span></pre>
<pre style="background:white"><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif">RealmResource realm2 = </span><b><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif;color:#660E7A">adminClient</span></b><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif">.realms().realm(</span><b><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif;color:green">&quot;realm2&quot;</span></b><span style="font-size:9.0pt;font-family:&quot;DejaVu Sans Mono&quot;,serif">);<o:p></o:p></span></pre>
<pre style="background:white"><span style="font-size:11.5pt;background:#E4E4FF">realm1</span><span style="font-size:11.5pt">.clients().create(clientRepresentation);<o:p></o:p></span></pre>
<pre style="background:white"><span style="font-size:11.5pt;background:#E4E4FF">realm</span><span style="font-size:11.5pt">2.clients().create(clientRepresentation);<o:p></o:p></span></pre>
<pre style="background:white"><span style="font-size:11.5pt"><o:p>&nbsp;</o:p></span></pre>
<p class="MsoNormal"><br>
For update you can take a look at some of our tests, which are updating client. For example this one :
<a href="https://github.com/mposolda/keycloak/blob/master/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ClientTest.java#L183">
https://github.com/mposolda/keycloak/blob/master/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ClientTest.java#L183</a><br>
<br>
Note that you need to know client Id (this is different thant clientId). The easiest is to set it manually in representation before you create client (via client.setId ) like it's done in this test.<br>
<br>
Marek<br>
<br>
On 26/05/16 14:54, Haim Vana wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Any idea regarding the below ?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">As a workaround how can I update existing client programmatically ? I couldn't find it in the admin API.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Thanks again,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Haim.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> Haim Vana
<br>
<b>Sent:</b> Thursday, May 26, 2016 2:17 PM<br>
<b>To:</b> <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<b>Subject:</b> How to create the same client (same id) for multiple realms programmatically
</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Hi,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">I am trying to create the same client for many realms, however it creates it only once, probably because they have the same id, however in UI I am able to create
 it.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">Any idea how I can create the same client for different realms programmatically with the same id ?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D">This is my code sample:</span><o:p></o:p></p>
<pre style="background:white"><span style="font-size:11.5pt">ClientRepresentation clientRepresentation = </span><b><span style="font-size:11.5pt;color:navy">new </span></b><span style="font-size:11.5pt">ClientRepresentation();<o:p></o:p></span></pre>
<pre style="background:white"><span style="font-size:11.5pt">clientRepresentation.setId(clientId); // Same clientId for all reamls</span><o:p></o:p></pre>
<p class="MsoNormal" style="background:white"><span style="font-size:11.5pt">realm</span><span style="font-size:11.5pt;font-family:&quot;Courier New ;color:black&quot;,serif">.clients().create(clientRepresentation); // Client is created only for first realm</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Any advice will be appreciated,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Haim.</span><o:p></o:p></p>
<p class="MsoNormal">The information contained in this message is proprietary to the sender, protected from disclosure, and may be privileged. The information is intended to be conveyed only to the designated recipient(s) of the message. If the reader of this
 message is not the intended recipient, you are hereby notified that any dissemination, use, distribution or copying of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately
 by replying to the message and deleting it from your computer. Thank you. <br>
<br>
<br>
<o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>keycloak-user mailing list<o:p></o:p></pre>
<pre><a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><o:p></o:p></pre>
<pre><a href="https://lists.jboss.org/mailman/listinfo/keycloak-user">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
The information contained in this message is proprietary to the sender, protected from disclosure, and may be privileged. The information is intended to be conveyed only to the designated recipient(s) of the message. If the reader of this message is not the
 intended recipient, you are hereby notified that any dissemination, use, distribution or copying of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by replying to
 the message and deleting it from your computer. Thank you.
</body>
</html>