Include any claims specified via request.claims in the JWT access token.#927
Open
rorymurphy wants to merge 1 commit intooauthlib:masterfrom
Open
Include any claims specified via request.claims in the JWT access token.#927rorymurphy wants to merge 1 commit intooauthlib:masterfrom
rorymurphy wants to merge 1 commit intooauthlib:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #926 by ensuring that claims specified via request.claims in the request validator are included in the JWT access token, rather than being ignored as they were previously.
Key Changes:
- Modified
signed_token_generator()to merge existing request claims with kwargs-provided claims instead of overwriting them - Added test coverage to verify that both request claims and generator kwargs are included in the final token
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
oauthlib/oauth2/rfc6749/tokens.py |
Updated signed_token_generator() to preserve and merge existing request.claims with new claims from kwargs, properly handling cases where the attribute doesn't exist or is None |
tests/oauth2/rfc6749/test_tokens.py |
Added test case to verify that both request-level claims and generator-level claims are correctly merged and passed to the JWT generation function |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.assertEqual(result, 0) | ||
|
|
||
| @mock.patch("oauthlib.common.generate_signed_token") | ||
| def test_signed_token_generator_repsects_request_claims(self, common_generate): |
There was a problem hiding this comment.
Spelling error in test method name: "repsects" should be "respects".
Suggested change
| def test_signed_token_generator_repsects_request_claims(self, common_generate): | |
| def test_signed_token_generator_respects_request_claims(self, common_generate): |
Member
There was a problem hiding this comment.
can you please cross check this?
|
Hello @auvipy, @JonathanHuot , could you review this fix? Thanks |
auvipy
requested changes
Apr 22, 2026
| self.assertEqual(result, 0) | ||
|
|
||
| @mock.patch("oauthlib.common.generate_signed_token") | ||
| def test_signed_token_generator_repsects_request_claims(self, common_generate): |
Member
There was a problem hiding this comment.
can you please cross check this?
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.
Per the docs, it appears any claims added to the request in the request validator should appear in the JWT access token. Presently, these claims appear to be ignored.
Fixes #926