oauthlib / oauthlib/oauthlib

Improve error message when application/x-www-form-urlencoded is not used for token requests

Open
#928 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3k
Forks
529
PR merge metrics
No merged PRs in 30d

Description

Describe the feature

When a client sends an OAuth2 token request with an incorrect Content-Type header (for example, application/json instead of the required application/x-www-form-urlencoded), oauthlib currently responds with unsupported_grant_type.
This is misleading because the grant type itself is correct the issue is the request encoding.
The feature request is to return a more accurate and descriptive error message, such as:
"Content-Type must be application/x-www-form-urlencoded."
Additional context

This improvement would help developers quickly diagnose incorrect request formatting instead of searching for issues with their grant type.
The feature applies to OAuth2 and affects server-side processing of token endpoint requests.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the server-side OAuth2 token endpoint processing described in the issue and reproduce a token request using application/json instead of application/x-www-form-urlencoded. The work is done when the incorrect encoding produces a clear Content-Type error while correctly encoded requests continue to process normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, authentication, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.