modelcontextprotocol / modelcontextprotocol/csharp-sdk

Passing ACR_VALUES TO Token Endpoint

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

Nobody has claimed this yet.

enhancement needs confirmation
Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Description

The ClientOAuthProvider can manage acr requests to the authorize endpoint via the _additionalAuthorizationParameters but the token endpoint does not support additional parameters.

internal sealed partial class ClientOAuthProvider
{
    private readonly IDictionary<string, string> _additionalAuthorizationParameters;
}
...
 private Uri BuildAuthorizationUrl(
     ProtectedResourceMetadata protectedResourceMetadata,
     AuthorizationServerMetadata authServerMetadata,
     string codeChallenge)
{
...
foreach (var kvp in _additionalAuthorizationParameters)
{
    queryParamsDictionary.Add(kvp.Key, kvp.Value);
}

var queryParams = HttpUtility.ParseQueryString(string.Empty);
foreach (var kvp in queryParamsDictionary)
{
    queryParams[kvp.Key] = kvp.Value;
}

var uriBuilder = new UriBuilder(authServerMetadata.AuthorizationEndpoint)
{
    Query = queryParams.ToString()
};


BUT IN only the token endpoint is used. No additional params are passed. This is needed for multitenancy support.

 private async Task<TokenContainer> ExchangeCodeForTokenAsync(
     ProtectedResourceMetadata protectedResourceMetadata,
     AuthorizationServerMetadata authServerMetadata,
     string authorizationCode,
     string codeVerifier,
     CancellationToken cancellationToken)
....
 using var request = new HttpRequestMessage(HttpMethod.Post, authServerMetadata.TokenEndpoint)
 {
     Content = requestContent
 };

Please see https://www.rfc-editor.org/rfc/rfc6749#section-3.2 for Token Endpoint Spec as it is supported and part of spec.

The endpoint URI MAY include an "application/x-www-form-urlencoded"
formatted (per Appendix B) query component ([RFC3986] Section 3.4),
which MUST be retained when adding additional query parameters. The
endpoint URI MUST NOT include a fragment component.

Can this please be added to ClientOAUthProvider for ExchangeToken and Refresh Token please

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 with ClientOAuthProvider, especially ExchangeCodeForTokenAsync and the existing _additionalAuthorizationParameters handling in BuildAuthorizationUrl. Trace how the token and refresh requests are constructed, then inspect the surrounding tests if present. Done means the requested additional parameters are supported for both token exchange and refresh while preserving the endpoint behavior described in RFC 6749.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, authentication
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.