Add ExtraHeaderParameters and ExtraQueryParameters support to DownstreamApi#3413
Merged
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>
Copilot
AI
changed the title
[WIP] [Feature Request] Send ExtraHeaderParameters and ExtraQueryParameters on DownstreamApisOptions
Add ExtraHeaderParameters and ExtraQueryParameters support to DownstreamApi
Jul 14, 2025
jmprieur
reviewed
Jul 14, 2025
Collaborator
jmprieur
left a comment
There was a problem hiding this comment.
A few suggestions for improvements
Collaborator
|
@copilot I've reviewed the PR and have suggestions for improvements |
…rParameters and ExtraQueryParameters Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
Contributor
Author
I've implemented the improvements by removing the unnecessary helper methods |
…ExtraQueryParameters access Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
jmprieur
reviewed
Jul 14, 2025
Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
jmprieur
reviewed
Jul 15, 2025
tests/Microsoft.Identity.Web.Test/DownstreamWebApiSupport/ExtraParametersTests.cs
Outdated
Show resolved
Hide resolved
tests/Microsoft.Identity.Web.Test/DownstreamWebApiSupport/ExtraParametersTests.cs
Outdated
Show resolved
Hide resolved
tests/Microsoft.Identity.Web.Test/DownstreamWebApiSupport/ExtraParametersTests.cs
Outdated
Show resolved
Hide resolved
…Options directly Co-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
This was referenced Dec 8, 2025
This was referenced Dec 18, 2025
This was referenced Dec 29, 2025
Closed
This was referenced Jan 5, 2026
Closed
This was referenced Jan 26, 2026
Open
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 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.