-
Notifications
You must be signed in to change notification settings - Fork 249
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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>
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
|
@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>
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
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 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.