2

I try to login with signed JWT, I follow this example, https://github.com/thomasdarimont/spring-boot-keycloak-jwe-example.

However when I try to get the token with curl with the following script

KC_USERNAME=root
KC_PASSWORD=casiopea
KC_CLIENT_ID=jweclient
KC_CLIENT_SECRET=418d630c-44cb-4f11-9dcc-a0c72dfc9f85
KC_ISSUER=http://localhost:8080/auth/realms/jwedemo

KC_RESPONSE=$(
curl
-d “client_id=$KC_CLIENT_ID”
-d “client_secret=$KC_CLIENT_SECRET”
-d “username=$KC_USERNAME”
-d “password=$KC_PASSWORD”
-d “client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer”
-d “grant_type=password”
-d “scope=profile openid”
-d “client_assertion=eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICIyZTJlOWU4NC04Y2UxLTQ5NWEtOGY5Zi1jMWNiNDNhYmY5NzQifQ.eyJleHAiOjAsImlhdCI6MTU4OTgyMzEyMSwianRpIjoiOTg2NjVjYWYtY2RmMy00Y2JkLTgxYzUtODBiNGY3MWNmZDJhIiwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwL2F1dGgvcmVhbG1zL2p3ZWRlbW8iLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvandlZGVtbyIsInR5cCI6IlJlZ2lzdHJhdGlvbkFjY2Vzc1Rva2VuIiwicmVnaXN0cmF0aW9uX2F1dGgiOiJhdXRoZW50aWNhdGVkIn0.O0TG-CwW0vnyokrhzK9k3QKkt5n71P6FUheBD4hTpG8”
“$KC_ISSUER/protocol/openid-connect/token”
)
echo $KC_RESPONSE | jq -C .

always throws

{ “error”: “unauthorized_client”, “error_description”: “Client authentication with signed JWT failed: Can’t identify client. Issuer missing on JWT token” } I don’t know how to get client_assertion, I Try different ways to do it but it does not work.

user1106585
  • 31
  • 1
  • 2

1 Answers1

1

Your client_assertion is missing 'sub' claim, and its value should be 'client_id'.

Documentation at https://kb.authlete.com/en/s/oauth-and-openid-connect/a/client-secret-jwt helped me find out required claims for this api.

Yash
  • 214
  • 4
  • 16