Improve Content-Type Validation for Token Endpoint Requests#929
Open
Kris-Val wants to merge 1 commit intooauthlib:masterfrom
Open
Improve Content-Type Validation for Token Endpoint Requests#929Kris-Val wants to merge 1 commit intooauthlib:masterfrom
Kris-Val wants to merge 1 commit intooauthlib:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces explicit Content-Type validation for OAuth2 token endpoint requests, addressing issue #928. When a request's Content-Type header doesn't match the expected application/x-www-form-urlencoded, the server now returns a clear error message.
Key changes:
- Added
UnsupportedContentTypeErrorexception class for Content-Type validation errors - Implemented
_raise_on_bad_content_type()validation method in the base endpoint - Integrated Content-Type validation into token endpoint request processing
- Added comprehensive test coverage for the new validation across multiple grant types
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| oauthlib/oauth2/rfc6749/errors.py | Defines new UnsupportedContentTypeError exception for Content-Type validation failures |
| oauthlib/oauth2/rfc6749/endpoints/base.py | Implements _raise_on_bad_content_type() validation method to check Content-Type headers |
| oauthlib/oauth2/rfc6749/endpoints/token.py | Integrates Content-Type validation into token request validation flow |
| tests/oauth2/rfc6749/endpoints/test_error_responses.py | Adds test cases verifying Content-Type validation across web, legacy, and backend application servers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
auvipy
requested changes
Nov 30, 2025
02e8cbc to
922b9fc
Compare
This change introduces explicit validation of the Content-Type header for token endpoint requests. When the request’s Content-Type does not match the expected value, it now raises a clear and descriptive error.
922b9fc to
68caf4f
Compare
auvipy
reviewed
Mar 9, 2026
Member
auvipy
left a comment
There was a problem hiding this comment.
not sure why the CI is not running
auvipy
requested changes
Apr 22, 2026
Member
auvipy
left a comment
There was a problem hiding this comment.
can you please fix the lint errors?
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.
This change introduces explicit validation of the Content-Type header for token endpoint requests. When the request’s Content-Type does not match the expected value, it now raises a clear and descriptive error.
Issue #928 – oauthlib/oauthlib