On Keycloak 23.0.4
the auth in the URL has been left out, so for a client it is now i.e.:
curl -k https://IP-ADDRESS:8443/realms/Test123/protocol/openid-connect/token -d "grant_type=client_credentials" -d "client_id=SURE_APP" -d "client_secret=ca3c4212-f3e8-43a4-aa14-1011c7601c67" -d "scope=openid"
To get the id_token
for a user, the user credentials have to be added and the grant_type
has to be changed to password, i.e.:
curl -k https://IP-ADDRESS:8443/realms/Test123/protocol/openid-connect/token -d "grant_type=password" -d "client_id=SURE_APP" -d "client_secret=ca3c4212-f3e8-43a4-aa14-1011c7601c67" -d "scope=openid" -d "username=jdoe" -d "password=jdoe"
Correction: the way described above and which was also mentioned by previous contributors, still gives you the access_token, NOT the id_token. It contains user information, yes, but is still not the "real thing".
Studying the openid specification (https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth) I found out that a way to get the id_token would be to specify the response_type (=grant_type) "id_token", but this, according to the error message received, is not supported by Keycloak.
So the only way I found is to go via the code flow: first ask for the code (grant_type=authorization_code) and then by asking for the token you will not only get the access_token but also the id_token, which doesn't contain all the authority-related claims.
I have been working with Keycloak in Java (Spring, JEE) and postman.
@Pablo which Keycloak Adapter are you using? Did you take a look at official documentation regarding Security Context ? – Commune/token
response. – Dnepropetrovskid_token
is used to sensitive information and that is the requirement that I have now. – Dnepropetrovsk