<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: How to Set Up Keycloak Admin Client with Spring Boot and Kotlin?	</title>
	<atom:link href="https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/</link>
	<description>Kotlin &#38; Backend Tutorials - Learn Through Practice.</description>
	<lastBuildDate>Wed, 16 Apr 2025 04:50:29 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>
		By: Karo		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-32</link>

		<dc:creator><![CDATA[Karo]]></dc:creator>
		<pubDate>Mon, 27 Nov 2023 19:18:53 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-32</guid>

					<description><![CDATA[Hi Piotr,

first of all thanks for the clear guide, very helpful.

I made it work on my end with the keycloak version 22.0.3. I noticed a strange issue, when I did bulk user creation (loop through 50 users and call single user creation one by one), the first ~10 is created successfully (including extracting the newly created ids), but then it throws this exception:
Caused by: jakarta.ws.rs.WebApplicationException: Create method returned status Bad Request (Code: 400); expected status: Created (201)
. This is thrown when I try to extract the newly created user id from the header (after ~10 successfully created user and extracted ids) . 

Do you maybe know why this issue appears? 

Best,
Karo]]></description>
			<content:encoded><![CDATA[<p>Hi Piotr,</p>
<p>first of all thanks for the clear guide, very helpful.</p>
<p>I made it work on my end with the keycloak version 22.0.3. I noticed a strange issue, when I did bulk user creation (loop through 50 users and call single user creation one by one), the first ~10 is created successfully (including extracting the newly created ids), but then it throws this exception:<br />
Caused by: jakarta.ws.rs.WebApplicationException: Create method returned status Bad Request (Code: 400); expected status: Created (201)<br />
. This is thrown when I try to extract the newly created user id from the header (after ~10 successfully created user and extracted ids) . </p>
<p>Do you maybe know why this issue appears? </p>
<p>Best,<br />
Karo</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Piotr		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-31</link>

		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Mon, 05 Sep 2022 05:23:35 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-31</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-30&quot;&gt;Alex&lt;/a&gt;.

Hi man! 
I haven&#039;t verified this approach, but looks that the API exposes an endpoint, which you might be interested in: 
PUT /{realm}/users/{id}/reset-password  (link to the docs: https://www.keycloak.org/docs-api/15.0/rest-api/) 
The example flow would look, as follow: 
On your side: 
1. Create table, for example &quot;reset_tokens&quot; with &quot;token&quot;, &quot;email&quot;, &quot;expires_at&quot; columns. 
2. Expose new the endpoint, which user will be using to trigger the flow (he will have to send e-mail in the request body) 
3. When user hits this endpoint, you should generate a new entry in the table. Check if the email exists in the system. If yest, then for the &quot;token&quot;, generate some random value and send this to the email provided by the user. (in real-life, this is done by creating a link with this token appended in the end so that the front-end automatically capture that and send to the server)
4. Create second endpoint. This will take two values in the request body: token and new password as text. When user hits this endpoint, then you check the table by the given token value (and also expires_at &#060; now() ). If such a value is found, then you query the Keycloak endpoint.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-30">Alex</a>.</p>
<p>Hi man!<br />
I haven&#8217;t verified this approach, but looks that the API exposes an endpoint, which you might be interested in:<br />
PUT /{realm}/users/{id}/reset-password  (link to the docs: <a href="https://www.keycloak.org/docs-api/15.0/rest-api/" rel="nofollow ugc">https://www.keycloak.org/docs-api/15.0/rest-api/</a>)<br />
The example flow would look, as follow:<br />
On your side:<br />
1. Create table, for example &#8220;reset_tokens&#8221; with &#8220;token&#8221;, &#8220;email&#8221;, &#8220;expires_at&#8221; columns.<br />
2. Expose new the endpoint, which user will be using to trigger the flow (he will have to send e-mail in the request body)<br />
3. When user hits this endpoint, you should generate a new entry in the table. Check if the email exists in the system. If yest, then for the &#8220;token&#8221;, generate some random value and send this to the email provided by the user. (in real-life, this is done by creating a link with this token appended in the end so that the front-end automatically capture that and send to the server)<br />
4. Create second endpoint. This will take two values in the request body: token and new password as text. When user hits this endpoint, then you check the table by the given token value (and also expires_at &lt; now() ). If such a value is found, then you query the Keycloak endpoint.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Alex		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-30</link>

		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Mon, 05 Sep 2022 00:46:52 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-30</guid>

					<description><![CDATA[Hi Piotr, thank you very much for this tutorial! I need to allow users to change their passwords and emails directly from my application(SpringBoot) . Is this possible with keycloak-admin-client and if yes, could you please show how? Thanks in advance, Alex]]></description>
			<content:encoded><![CDATA[<p>Hi Piotr, thank you very much for this tutorial! I need to allow users to change their passwords and emails directly from my application(SpringBoot) . Is this possible with keycloak-admin-client and if yes, could you please show how? Thanks in advance, Alex</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Piotr		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-29</link>

		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Tue, 29 Mar 2022 04:38:04 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-29</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-23&quot;&gt;channing&lt;/a&gt;.

Hi Pedro

Could you please upload the code to GitHub? This way I will be able to help]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-23">channing</a>.</p>
<p>Hi Pedro</p>
<p>Could you please upload the code to GitHub? This way I will be able to help</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Pedro		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-28</link>

		<dc:creator><![CDATA[Pedro]]></dc:creator>
		<pubDate>Mon, 28 Mar 2022 16:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-28</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-23&quot;&gt;channing&lt;/a&gt;.

For me it&#039;s the same. I update my user but nothing changes on my keycloak server. However, if I send a second update request, the user appears as updated as my first request. I have tried several pieces of code, but nothing works. I&#039;m using the version 17.0.1 for spring boot.

 @Override
    public void updateUser(User user) {
        UsersResource instance = getInstance().realm(realm).users();
        UserResource userResource = instance.get(user.getSecurityProviderId());
        UserRepresentation userRepresentation = userResource.toRepresentation();

        userRepresentation.setFirstName(user.getName());
        userRepresentation.setLastName(user.getSurname());
        userRepresentation.setEmail(user.getEmail());

        userResource.update(userRepresentation);
    }]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-23">channing</a>.</p>
<p>For me it&#8217;s the same. I update my user but nothing changes on my keycloak server. However, if I send a second update request, the user appears as updated as my first request. I have tried several pieces of code, but nothing works. I&#8217;m using the version 17.0.1 for spring boot.</p>
<p> @Override<br />
    public void updateUser(User user) {<br />
        UsersResource instance = getInstance().realm(realm).users();<br />
        UserResource userResource = instance.get(user.getSecurityProviderId());<br />
        UserRepresentation userRepresentation = userResource.toRepresentation();</p>
<p>        userRepresentation.setFirstName(user.getName());<br />
        userRepresentation.setLastName(user.getSurname());<br />
        userRepresentation.setEmail(user.getEmail());</p>
<p>        userResource.update(userRepresentation);<br />
    }</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Piotr		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-27</link>

		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Mon, 28 Mar 2022 05:11:29 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-27</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-23&quot;&gt;channing&lt;/a&gt;.

OK, hello once again :) 
I&#039;ve just set up Keycloak from scratch: 
1. Cloned the repository
2. Set Up config (step 2 + creating a realm called example from the link I&#039;ve provided) 
3. Update application.yaml and put credentials.secret with appropriate value 
4. Added a bit modified code (I used Kotlin)
And this seems to be working fine, because when I update and then get user details by ID I receive: 
&quot;attributes&quot;: {
  &quot;WECOM_USER_ID&quot;: [
    &quot;myTestId&quot;  
  ]
}
I&#039;ve uploaded my example as this commit: https://github.com/codersee-blog/kotlin-spring-boot-keycloak-admin/commit/9c4d593652b39de3c2482f5d1707928be14e1903

Let me know if this is still the issue]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-23">channing</a>.</p>
<p>OK, hello once again 🙂<br />
I&#8217;ve just set up Keycloak from scratch:<br />
1. Cloned the repository<br />
2. Set Up config (step 2 + creating a realm called example from the link I&#8217;ve provided)<br />
3. Update application.yaml and put credentials.secret with appropriate value<br />
4. Added a bit modified code (I used Kotlin)<br />
And this seems to be working fine, because when I update and then get user details by ID I receive:<br />
&#8220;attributes&#8221;: {<br />
  &#8220;WECOM_USER_ID&#8221;: [<br />
    &#8220;myTestId&#8221;<br />
  ]<br />
}<br />
I&#8217;ve uploaded my example as this commit: <a href="https://github.com/codersee-blog/kotlin-spring-boot-keycloak-admin/commit/9c4d593652b39de3c2482f5d1707928be14e1903" rel="nofollow ugc">https://github.com/codersee-blog/kotlin-spring-boot-keycloak-admin/commit/9c4d593652b39de3c2482f5d1707928be14e1903</a></p>
<p>Let me know if this is still the issue</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Piotr		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-26</link>

		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Mon, 28 Mar 2022 04:57:16 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-26</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-19&quot;&gt;Piyush&lt;/a&gt;.

Hello! :) 
I&#039;m afraid that it might be a small mistake in your configuration (sometimes happens, even though we try to do everything letter by letter). I&#039;ve just cloned the repository and set it up and both role and user was created successfully. (please remember about creating realm called example- chapter 2). It&#039;s really hard to help what might be the cause without seeing the code
When it comes to creating the continuation with groups and policy/permissions- I don&#039;t want to promise anything, because I got plenty of ongoing work that needs to be finished (and also I&#039;ve used a Keycloak over the year ago last time). 
Nevertheless, policy should (not sure) work out of the box with &#039;hasPermission&#039; (similarly, like I do in the second tutorial with securing endpoints by &#039;hasRole&#039;)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-19">Piyush</a>.</p>
<p>Hello! 🙂<br />
I&#8217;m afraid that it might be a small mistake in your configuration (sometimes happens, even though we try to do everything letter by letter). I&#8217;ve just cloned the repository and set it up and both role and user was created successfully. (please remember about creating realm called example- chapter 2). It&#8217;s really hard to help what might be the cause without seeing the code<br />
When it comes to creating the continuation with groups and policy/permissions- I don&#8217;t want to promise anything, because I got plenty of ongoing work that needs to be finished (and also I&#8217;ve used a Keycloak over the year ago last time).<br />
Nevertheless, policy should (not sure) work out of the box with &#8216;hasPermission&#8217; (similarly, like I do in the second tutorial with securing endpoints by &#8216;hasRole&#8217;)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Piotr		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-25</link>

		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Fri, 25 Mar 2022 05:44:09 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-25</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-23&quot;&gt;channing&lt;/a&gt;.

Hello! 
Let me get back to you with the answer during the weekend :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-23">channing</a>.</p>
<p>Hello!<br />
Let me get back to you with the answer during the weekend 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: channing		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-24</link>

		<dc:creator><![CDATA[channing]]></dc:creator>
		<pubDate>Thu, 24 Mar 2022 05:50:12 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-24</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-19&quot;&gt;Piyush&lt;/a&gt;.

I have encountered the error also, and I don&#039;t how to solve it]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-19">Piyush</a>.</p>
<p>I have encountered the error also, and I don&#8217;t how to solve it</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: channing		</title>
		<link>https://blog.codersee.com/how-to-set-up-keycloak-admin-client-with-spring-boot-and-kotlin/#comment-23</link>

		<dc:creator><![CDATA[channing]]></dc:creator>
		<pubDate>Thu, 24 Mar 2022 05:49:05 +0000</pubDate>
		<guid isPermaLink="false">http://codersee.com/?p=1653#comment-23</guid>

					<description><![CDATA[HI Piotr, 
Thanks for you article, it helps a lot. Here I have encounter a problem, I read users from keycloak successfully, but I can not update user&#039;s atrributes succesfully. Following is my java code :
@Override
    public void updateWecomUserId(String id, String wecomUserId) {    
        UserResource userResource = keycloak.realm(realm).users().get(id);
        UserRepresentation userPresentation = userResource.toRepresentation();
        Predicate&#060;Map&#060;String, List&#062;&#062; prdc = p -&#062; p == null;
        if (prdc.test(userPresentation.getAttributes())) {
            userPresentation.setAttributes(new HashMap());
        }
        userPresentation.setLastName(&quot;===test===&quot;);
        userPresentation.getAttributes().put(WECOM_USER_ID,
        Collections.singletonList(wecomUserId));
        // for the update , it throws exception:javax.ws.rs.BadRequestException: HTTP 400 Bad Request
        userResource.update(userPresentation);

    } 
Do you know what mistake I have made ? Thanks a lot.]]></description>
			<content:encoded><![CDATA[<p>HI Piotr,<br />
Thanks for you article, it helps a lot. Here I have encounter a problem, I read users from keycloak successfully, but I can not update user&#8217;s atrributes succesfully. Following is my java code :<br />
@Override<br />
    public void updateWecomUserId(String id, String wecomUserId) {<br />
        UserResource userResource = keycloak.realm(realm).users().get(id);<br />
        UserRepresentation userPresentation = userResource.toRepresentation();<br />
        Predicate&lt;Map&lt;String, List&gt;&gt; prdc = p -&gt; p == null;<br />
        if (prdc.test(userPresentation.getAttributes())) {<br />
            userPresentation.setAttributes(new HashMap());<br />
        }<br />
        userPresentation.setLastName(&#8220;===test===&#8221;);<br />
        userPresentation.getAttributes().put(WECOM_USER_ID,<br />
        Collections.singletonList(wecomUserId));<br />
        // for the update , it throws exception:javax.ws.rs.BadRequestException: HTTP 400 Bad Request<br />
        userResource.update(userPresentation);</p>
<p>    }<br />
Do you know what mistake I have made ? Thanks a lot.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: blog.codersee.com @ 2026-05-15 18:08:01 by W3 Total Cache
-->