[v1.x] Add subject and claims to AccessToken#2690
Merged
Merged
Conversation
Adds optional `subject` and `claims` fields to `AccessToken` so token verifiers can surface the resource owner (`sub`) and any additional claims to request handlers. `subject` is also added to `AuthorizationCode` and `RefreshToken` so the value can be carried through code-for-token exchange and refresh. The simple-auth example threads the subject from login through the introspection response and back into the verifier; the integration test exercises the full code → token → refresh → load chain. v1.x backport of #2686. Closes #1038. Reported-by: Thomas Steinacher <@thomasst> Reported-by: Yukuan Jia <@yukuanj> Reported-by: Shivam Aggarwal <@shivama205>
pcarleton
approved these changes
May 26, 2026
This was referenced May 26, 2026
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.
v1.x backport of #2686.
Summary
Adds optional
subjectandclaimsfields toAccessTokenso token verifiers can surface the resource owner (sub) and any additional claims to request handlers, and addssubjecttoAuthorizationCodeandRefreshTokenso the value can be carried through code-for-token exchange and refresh.The simple-auth example is updated to thread the subject from login through the introspection response and back into the verifier; the integration test exercises the full code → token → refresh → load chain.
Closes #1038. Supersedes #2209 and #1517 — see #2686 for context. Thanks to @thomasst, @yukuanj, and @shivama205 for the prior work.
Differences from #2686
The
Context.client_iddocstring clarification lands infastmcp/server.pyrather thanmcpserver/context.py; the integration test threading lands intests/server/fastmcp/auth/test_auth_integration.py. Otherwise identical.Breaking changes
None. All new fields are optional with
Nonedefaults.AI Disclaimer