Uh oh!
There was an error while loading. Please reload this page.
Add ExtraHeaderParameters and ExtraQueryParameters support to DownstreamApi - #3413
Conversation
…ueryParameters to DownstreamApiOptions Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
…ownstreamApi Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
…tion Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
Jean-Marc Prieur (jmprieur)
left a comment
There was a problem hiding this comment.
A few suggestions for improvements
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Jean-Marc Prieur (jmprieur)
commented
Jul 14, 2025
Copilot I've reviewed the PR and have suggestions for improvements |
…rParameters and ExtraQueryParameters Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
I've implemented the improvements by removing the unnecessary helper methods |
…ExtraQueryParameters access Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
Jean-Marc Prieur (jmprieur)
left a comment
There was a problem hiding this comment.
Copilot I left a few comments
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…Options directly Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
This PR implements support for
ExtraHeaderParametersandExtraQueryParametersproperties onDownstreamApiOptionsto simplify adding custom headers and query parameters to downstream API requests.Problem
Previously, developers had to use the complex
CustomizeHttpRequestMessagedelegate to add custom headers and query parameters to downstream API calls:Solution
This PR adds support for the more convenient
ExtraHeaderParametersandExtraQueryParametersproperties:Implementation Details
Key Features
DownstreamApiOptionsfor backward compatibilityUri.EscapeDataStringCustomizeHttpRequestMessagedelegateTechnical Changes
GetExtraHeaderParameters()andGetExtraQueryParameters()helper methods inDownstreamApiclassUpdateRequestAsync()method to apply extra parameters beforeCustomizeHttpRequestMessageis calledExtraParametersTests.csHeader Processing
TryAddWithoutValidationto support custom header schemesCustomizeHttpRequestMessagedelegate, allowing for overrideQuery Parameter Processing
Testing
The implementation includes comprehensive tests covering:
Backward Compatibility
The implementation uses reflection to detect if these properties exist on
DownstreamApiOptions, ensuring full backward compatibility with different versions of the Microsoft.Identity.Abstractions package.Dependencies
This feature assumes that the
ExtraHeaderParametersandExtraQueryParametersproperties will be added toDownstreamApiOptionsin the Microsoft.Identity.Abstractions package as mentioned in the related issue.Fixes#3387.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.