# How to integrate keycloak on a simple spring boot example

**URL:** https://forum.keycloak.org/t/how-to-integrate-keycloak-on-a-simple-spring-boot-example/4728
**Category:** Miscellanaeous
**Created:** [September 5, 2020, 12:24am UTC](https://forum.keycloak.org/t/how-to-integrate-keycloak-on-a-simple-spring-boot-example/4728 "2020-09-05T00:24:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![wallyson](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wallyson](https://forum.keycloak.org/u/wallyson)
#### Post date: [September 5, 2020, 12:24am UTC](https://forum.keycloak.org/t/how-to-integrate-keycloak-on-a-simple-spring-boot-example/4728/1 "2020-09-05T00:24:46Z")

</div>

I have the following simple example of a spring boot API that I’m testing with keycloak that was made based on [THIS EXAMPLE](https://github.com/keycloak/keycloak-quickstarts/tree/latest/app-authz-rest-springboot) but no matter what I do it doesn’t work. When I make the request to the protected endpoint nothing happens, no logs, nothing.  
What am I missing here ?

> <https://gist.github.com/wallysoncarvalho/10c8c19a91759b168328b04c96c1caaa>
>
> There are more than three files. show original

---

<div class="post-metadata">

### Author: ![Jakob](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/jakob/32/1242_2.png) [@Jakob](https://forum.keycloak.org/u/Jakob)
#### Post date: [September 5, 2020, 9:54am UTC](https://forum.keycloak.org/t/how-to-integrate-keycloak-on-a-simple-spring-boot-example/4728/2 "2020-09-05T09:54:10Z")

</div>

Did you tried it with Spring Security?

---

<div class="post-metadata">

### Author: ![wallyson](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wallyson](https://forum.keycloak.org/u/wallyson)
#### Post date: [September 5, 2020, 1:31pm UTC](https://forum.keycloak.org/t/how-to-integrate-keycloak-on-a-simple-spring-boot-example/4728/3 "2020-09-05T13:31:33Z")

</div>

No, but I believe that it should work like that, no?

Besides, does spring security have any advantage?

---

<div class="post-metadata">

### Author: ![zonaut](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/zonaut/32/666_2.png) [@zonaut](https://forum.keycloak.org/u/zonaut)
#### Post date: [September 5, 2020, 1:43pm UTC](https://forum.keycloak.org/t/how-to-integrate-keycloak-on-a-simple-spring-boot-example/4728/4 "2020-09-05T13:43:25Z")

</div>

The keycloak starter pulls in Spring Security so you’re already using it.  
Maybe you should create a git repo and share the link here so people can take a look at it instead of posting a couple of files.  
I don’t see the secret you’re using in the keycloak-config.json for starters or you replaced them with stars for which there is no point as you share you’re secret in the application.yml file.  
You should also take a look on how to configure _securityConstraints_ correctly as you’re config seems to contradict what your controller tries to do.

---

<div class="post-metadata">

### Author: ![wallyson](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wallyson](https://forum.keycloak.org/u/wallyson)
#### Post date: [September 5, 2020, 6:10pm UTC](https://forum.keycloak.org/t/how-to-integrate-keycloak-on-a-simple-spring-boot-example/4728/5 "2020-09-05T18:10:42Z")

</div>

@zonaut, thanks for the reply.  
I didn’t created a repo because this was supposed to be an EXTREMELY simple api just for tests. But you’re right, I’m going to present a better example.

The `keycloak-config.json` was automatically generated on keycloak export, I haven’t edited it’s content.

It’s weird but the \* _securityConstraints_\* it’s just like it was supposed to be (trying to protect  
what was supposed to be the public endpoint 😄 , it was some tests I was doing and I forgot to fix it).
