<div dir="ltr">The &#39;realm&#39; variable represents a RealmResource which is locked to a specific realm.<div><br></div><div>If you want to work with another realm you have to get a RealmResource for that realm.</div><div><br></div><div><br></div><div>For example:</div><div><br></div><div><font face="monospace, monospace">Keycloak adminClient = <span style="color:rgb(0,0,0);font-size:9pt">Keycloak.getInstance(</span><span style="font-size:9pt;color:rgb(0,128,0);font-weight:bold">&quot;<a href="http://localhost:8080/auth">http://localhost:8080/auth</a>&quot;</span><span style="color:rgb(0,0,0);font-size:9pt">,</span></font></div><pre style="color:rgb(0,0,0);font-size:9pt"><font face="monospace, monospace">        MASTER, ADMIN, ADMIN, Constants.ADMIN_CLI_CLIENT_ID);</font></pre><div><font face="monospace, monospace">RealmResource realm = adminClient.realms().get(&quot;MyRealm&quot;);</font></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 26, 2016 at 2:54 PM, Haim Vana <span dir="ltr">&lt;<a href="mailto:haimv@perfectomobile.com" target="_blank">haimv@perfectomobile.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">Any idea regarding the below ?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u> <u></u></span></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&#39;t find it in the admin API.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">Thanks again,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">Haim.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u> <u></u></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">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" target="_blank">keycloak-user@lists.jboss.org</a><br>
<b>Subject:</b> How to create the same client (same id) for multiple realms programmatically
<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u> <u></u></span></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.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u> <u></u></span></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 ?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f497d">This is my code sample:<u></u><u></u></span></p>
<pre style="background:white"><span style="font-size:11.5pt;color:black">ClientRepresentation clientRepresentation = </span><b><span style="font-size:11.5pt;color:navy">new </span></b><span style="font-size:11.5pt;color:black">ClientRepresentation();<br>clientRepresentation.setId(clientId); // Same clientId for all reamls<u></u><u></u></span></pre>
<p class="MsoNormal" style="background:white"><span style="font-size:11.5pt;font-family:&quot;Courier New&quot;;color:black;background:#e4e4ff">realm</span><span style="font-size:11.5pt;font-family:&quot;Courier New&quot;;color:black">.clients().create(clientRepresentation); //
 Client is created only for first realm<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Any advice will be appreciated,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Haim.<u></u><u></u></span></p>
</div></div></div><div><div class="h5">
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.
</div></div></div>

<br>_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br></blockquote></div><br></div>