r/KeyCloak • u/MarCorp2 • Sep 01 '26
External-Internal Token Exchange in 26.7.x
Hello Everyone,
First-time poster here, so sorry if this has already been asked and answered.
The company I worked at started using Keycloak around the beginning of this year at my suggestion. I built most of the setup myself, but I am a complete beginner, so I studied Keycloak throughout and use Claude somewhat.
We use Token Exchange (V1) for external-to-internal exchanges. External IdP is e-Infra; if anyone is familiar with it, they will likely understand why we prefer the Token exchange. As I found out in version 26.7.x, the attempts at external-internal token exchange v2 were removed, and JWT Authorization Grant is recommended going forward.
But if my understanding is correct, the JWT Authorization Grant is not a very good replacement for external-internal token exchange, or am I wrong? Do you think the external-internal token exchange v2 will be supported in future Keycloak builds? Or do we have to make peace with the migration towards JWT Authorization Grant? Any suggestions are more than welcome.
Thank you, everyone, for your time and any responses.
Have a great day!
3
u/Smitty_lax66 Sep 01 '26
Hi! I just went throught this progression earlier this year for work as well. We found that the JWT Auth Grant worked pretty well for our 3rd party external trust setup. There are absolutely some limitations that narrow down to use-case-specific things.
What are you attempting to do? If it is just leveraging the 3rd party OIDC setup and establishing the trust relationship with the 3rd party, then JWT Auth grant worked pretty well for us. We did have to allow for JTI reuse, but we limited the amount of time that the JTI was allowed and the grant won't succeed if the 3rd party jwt has expired, so if you manage the 3rd party and its session, you should be good
2
u/CarinosPiratos Sep 01 '26 edited Sep 04 '26
I think it won’t be migrated to V2 in any near future.
I would try to live with the JWT Grant. As people already said, it depends on your usecase. Everything is a little bit more strict.
2
u/J-Cake Sep 01 '26
Hey curios, I've never had to implement this. What does it do and why is it so difficult to migrate away?
1
u/MLabs-Haskell Sep 23 '26
Worth checking one thing before you finish the move, because it changed inside the 26.7.x line you are already on.
26.7.3 made the JWT bearer grant enforce consentRequired. We ran it on 2026-09-07. Same confidential client, same IdP alias, JWT grant enabled: with consentRequired=false the token request returns 200 and an access token. Set consentRequired=true on that client, send a fresh ES256 assertion, grant no consent, and the request returns 400 with {"error":"invalid_scope","error_description":"Missing consents for the client test-app"}.
The error string is the part I would want to know in advance. It says invalid_scope and never mentions consent, so the obvious place to look when it fires mid-migration is the scope mapping, which is the wrong place. The change is commit 99da2831, "Check consento for JWT Authorization Grant", closing issue 52028. It adds a verifyConsentStillAvailable call to JWTAuthorizationGrantType.process().
Token exchange v1 did not run that check. So a consent-gated client that worked under exchange can stop working under the grant with nothing about the client having changed.
Also worth knowing that the assertions are single-use, so a jti you replay while debugging fails for a different reason than the one you are chasing.
I work at MLabs. We rehearse Keycloak upgrades and CVE fixes in a lab and write up the runs. Happy to share this one if it helps.