I am using token_exchange to impersonate as another user in the same realm. This endpoint works fine for access_token retrieval. However since the access token will expire after sometime, I would like to also have refresh token so that I can refresh it when access_token would expire.
curl --location --request POST 'https://localhost:8080/auth/realms/demo/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:token-exchange' \
--data-urlencode 'client_id=democlient1' \
--data-urlencode 'requested_subject=3784f93a-fc2a-48c6-9641-3abb27724b06' \
--data-urlencode 'subject_token=xxxxx' \
--data-urlencode 'requested_token_type=urn:ietf:params:oauth:token-type:refersh_token'
When I set requested_token_type=urn:ietf:params:oauth:token-type:access_token it is working. I am getting the access_token and expires values.
As per https://github.com/keycloak/keycloak-documentation/blob/master/securing_apps/topics/token-exchange/token-exchange.adoc this documentation, I can get refresh_token, access_token and id_token.
Not sure why this is unsupported. Keycloak version is 11.0.3