Repository navigation
oauth: support the token exchange grant - #2500
Open
mjcheetham wants to merge 2 commits into
Open
mjcheetham wants to merge 2 commits into
mjcheetham wants to merge 2 commits into
Conversation
mjcheetham
marked this pull request as ready for review
November 9, 2026 14:08
mjcheetham
force-pushed
the
oauth-tokenexchange
branch
from
November 9, 2026 14:10
c167c5f to
abf5219
Compare
mjcheetham
force-pushed
the
oauth-tokenexchange
branch
3 times, most recently
from
November 10, 2026 14:35
3155fa1 to
6fbe176
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Token exchange may return a non-access token without validation, while the test server mishandles empty scopes and the API lacks JWT and target-parameter support.
4 open issues
What changed in this PR
Adds token-exchange support to the shared OAuth2 client, enabling host providers to exchange externally issued subject tokens for host access tokens.
Changes:
- Exposes an asynchronous token-exchange API and request handling.
- Adds token-type identifiers with enum serialization and parsing.
- Extends the in-memory OAuth server and tests for the exchange flow.
| File | Description |
|---|---|
src/TestInfrastructure/Objects/TestOAuth2Server.cs |
Adds subject-token grants and exchange responses. |
src/Core/Authentication/OAuth/OAuth2TokenType.cs |
Defines supported token types and wire-value conversions. |
src/Core/Authentication/OAuth/OAuth2Constants.cs |
Adds token-type identifiers and exchange request constants. |
src/Core/Authentication/OAuth/OAuth2Client.cs |
Adds the token-exchange API and HTTP request flow. |
src/Core.Tests/Authentication/OAuth2TokenTypeTests.cs |
Tests token-type serialization and parsing. |
src/Core.Tests/Authentication/OAuth2ClientTests.cs |
Tests a successful token exchange. |
Review effort: Balanced
Technically application/x-www-form-urlencoded data can contain repeated fields. Some OAuth RFCs allow for repeated fields, so we should support this. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Allow providers to exchange an existing access or refresh token for an OAuth access token, using the RFC 8693 token exchange grant. This enables authentication flows where a token issued by an external identity provider must be exchanged for one accepted by the host. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
mjcheetham
force-pushed
the
oauth-tokenexchange
branch
from
November 17, 2026 14:50
6fbe176 to
a28159c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Add support for the RFC 8693 token-exchange grant to the shared OAuth2 client. This enables providers to exchange a token issued by an external identity provider for an OAuth access token accepted by the target host.
Expose
GetTokenByTokenExchangeAsyncwith a subject token, its type, and the requested scopes. AddOAuth2TokenTypeand mappings for the standard token-type identifiers covering access tokens, refresh tokens, OpenID Connect ID tokens, and SAML 1.1/2.0 assertions.Extend the in-memory OAuth server with subject-token grants and add tests for the exchange flow, token-type serialization, and parsing.