modelcontextprotocol / modelcontextprotocol/typescript-sdk

OAuth Request Should Accept client_id and client_secret via Headers, Not Just in the Request Body

Open
#676 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auth enhancement needs decision P3
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

Describe the bug

When attempting to integrate with the OpenAI connector, the /token request fails because OpenAI sends the client_id and client_secret via the Authorization header, not in the request body.

The body /token request looks like this:

{
  "grant_type": "authorization_code",
  "code": "62cd621bf6e44fd88be3f98f3a8aba37",
  "redirect_uri": "https://chatgpt.com/connector_platform_oauth_redirect",
  "code_verifier": "mBLha_DC8fq_tnLSk3sWF0kpi3sda8yKKpsr_4k3vo"
}

Since the credentials are not in the body, the server does not recognize them and the authentication fails.


To Reproduce

Steps to reproduce the behavior:

  1. Attempt to integrate with the OpenAI connector.
  2. Use ProxyOAuthServerProvider for handling the /token request.
  3. Observe the failure due to missing credentials in the request body.

Expected behavior

From the code here, it appears that the implementation only reads client_id and client_secret from the request body.

This works for many clients, but fails in the case of OpenAI, which uses the Authorization header instead. The server should support extracting these credentials from the Authorization header (typically using Basic Auth) as well as from the body to ensure broader compatibility.

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 in src/server/auth/middleware/clientAuth.ts at the referenced credential-extraction logic. Reproduce a ProxyOAuthServerProvider /token request using the OpenAI connector pattern, where client_id and client_secret arrive through the Authorization header rather than the body. The work is done when header-based credentials are accepted while existing body-based requests continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.