#Unexpected response spring boot + keycloak app

1 messages · Page 1 of 1 (latest)

sweet plover
#

After requesting the endpoint: http://localhost:8083/microservice1/home
Once the "client credentials flow" chapter implement of this video https://www.youtube.com/watch?v=t9O99l4gjAc
I get the following answer (see attached image) instead of the expected one
https://github.com/onepseudoxy/spring-security-oauth2-keycloak-demo

Spring Security Oauth2 Tutorial with Keycloak - In this course, you will learn what is OAuth2 ? Why use it? And how to implement OAuth2 using Spring Security using Keycloak as an Authorization Server.

You can check out the source code here - https://github.com/SaiUpadhyayula/spring-security-oauth2-keycloak-demo

Timestamps of different sections...

▶ Play video
GitHub

Contribute to onepseudoxy/spring-security-oauth2-keycloak-demo development by creating an account on GitHub.

woven boltBOT
#

<@&1004656351647117403> please have a look, thanks.

woven boltBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

cosmic vessel
#

@sweet plover seems like the image didn't upload properly, or you're getting "Login with OAuth 2.0" as your response

twin sorrel
#

Can you also show us your oauth journey?

#

in the payload (as part of oauth), you should be providing a client_id, grant_type (and possibly a redirect_uri), then that should give you your bearer token

#

so if you're not doing that or doing something else, that's why you might be getting oauth issues

#

with the client credentials flow, I'm guessing you're doing server>server communication?

sweet plover
twin sorrel
#

That's ok then

#

The other questions I had?

sweet plover
# twin sorrel The other questions I had?
POST http://localhost:8180/realms/oauth2-demo-realm/protocol/openid-connect/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=oauth2-client-credentials&client_secret=NS2pyh7njjpGOdwbmew4tvVsBrvxGyxr

{% client.global.set("auth_token", JSON.parse(response.body).access_token); %}

### Authorization by token, part 2. Use token to authorize.
GET http://localhost:8083/microservice1/home
Authorization: Bearer {{auth_token}}```
woven boltBOT
# sweet plover ```### Authorization by token, part 1. Retrieve and save token. POST http://loca...

Detected code, here are some useful tools:

Formatted code
###Authorization by token, part1.Retrieve and save token.POST http : //localhost:8180/realms/oauth2-demo-realm/protocol/openid-connect/token
Content - Type : application / x - www - form - urlencoded grant_type = client_credentials & client_id = oauth2 - client - credentials & client_secret = NS2pyh7njjpGOdwbmew4tvVsBrvxGyxr {
   % client.global.set("auth_token", JSON.parse(response.body).access_token);
   % }
###Authorization by token, part2.Use token to authorize.GET http : //localhost:8083/microservice1/home
Authorization : Bearer {
    {
    auth_token}
}
sweet plover
#

I get the token without any issue

twin sorrel
#

Can't help further without seeing your code

#

If your code is exactly the same as that Github repo you linked then I would have to guess your keycloak setup is broken

cosmic vessel
#

There's no controller method for your call, is there?

#

Ah different branch

cosmic vessel
#

And why are you using jwk-set-uri but not issuer-uri?