- Notifications
You must be signed in to change notification settings - Fork242
Add ExtraHeaderParameters and ExtraQueryParameters support to DownstreamApi#3413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ueryParameters to DownstreamApiOptionsCo-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
…ownstreamApiCo-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
…tionCo-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
jmprieur left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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.
jmprieur commentedJul 14, 2025
@copilot I've reviewed the PR and have suggestions for improvements |
…rParameters and ExtraQueryParametersCo-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
I've implemented the improvements by removing the unnecessary helper methods |
…ExtraQueryParameters accessCo-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>
jmprieur left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot I left a few comments
tests/Microsoft.Identity.Web.Test/DownstreamWebApiSupport/ExtraParametersTests.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
tests/Microsoft.Identity.Web.Test/DownstreamWebApiSupport/ExtraParametersTests.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
tests/Microsoft.Identity.Web.Test/DownstreamWebApiSupport/ExtraParametersTests.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…Options directlyCo-authored-by: jmprieur <13203188+jmprieur@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
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 moreCopilot coding agent tips in the docs.