Skip to content

Simplify AddMicrosoftIdentityMessageHandler configuration overload - #4124

Merged
Bogdan Gavril (bgavrilMS) merged 2 commits into
masterfrom
copilot/fix-4123-message-handler-configuration
Oct 30, 2026
Merged

Bogdan Gavril (bgavrilMS) merged 2 commits into
masterfrom
copilot/fix-4123-message-handler-configuration

Conversation

Copilot AI commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Simplify AddMicrosoftIdentityMessageHandler configuration overload

  • Read the Contributor Guide and Code of Conduct.
  • Included regression tests.
  • Updated inline documentation and examples.
  • Linked an existing issue.

Configure the message handler without repeating the configuration section name.

Description

Callers can now pass a configuration section directly:

.AddMicrosoftIdentityMessageHandler(
    builder.Configuration.GetSection("DownstreamApis:apiservice"));

The existing overload remains supported with the same null checks and behavior. Its documentation now makes clear that sectionName is otherwise unused. The new overload reuses the existing delegate-based registration and still binds configuration when the handler is created.

Updated the public API records, documentation examples, and development sample. Regression coverage checks both overloads, including bound scopes and app-token settings for separate clients, null arguments, empty configuration, and builder chaining.

Validation: 42 focused tests passed on .NET 10; the TokenAcquisition netstandard2.0 build succeeded with no warnings or errors. The configured package feed failed during restore, so validation used NuGet.org without changing repository configuration.

Fixes #4123

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The deferred-binding behavior lacks a regression test for configuration changes after registration across both overloads.

1 open issue
What changed in this PR

Simplifies configuration-based HTTP message handler registration in Microsoft Identity Web by accepting a configuration section without a redundant section name, addressing #4123.

Changes:

  • Adds a configuration-only overload while preserving the existing overload’s null checks and deferred binding.
  • Updates public API records, documentation examples, and the development sample.
  • Expands regression coverage for both overloads, including per-client options, null arguments, empty configuration, and builder chaining.
File Description
tests/​Microsoft.Identity.Web.Test/​MicrosoftIdentityHttpClientBuilderExtensionsTests.cs Tests both overloads and verifies bound options for separate clients.
tests/​DevApps/​MtlsPop/​MtlsPopClient/​Program.cs Adopts the simplified overload.
src/​Microsoft.Identity.Web.TokenAcquisition/​PublicAPI/​NetFramework/​PublicAPI.Unshipped.txt Records the new .NET Framework API signature.
src/​Microsoft.Identity.Web.TokenAcquisition/​PublicAPI/​NetCore/​PublicAPI.Unshipped.txt Records the new .NET Core API signature.
src/​Microsoft.Identity.Web.TokenAcquisition/​MicrosoftIdentityHttpClientBuilderExtensions.cs Adds the overload and clarifies the legacy parameter’s behavior.
docs/​calling-downstream-apis/​token-binding.md Simplifies the configuration example.
docs/​calling-downstream-apis/​custom-apis.md Updates downstream API examples to omit redundant section names.

Review effort: Balanced

@bgavrilMS

Copy link
Copy Markdown
Member

Add a configuration-only overload while preserving the existing signature and validation. Update examples and verify bound options for both overloads.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bgavrilMS
Bogdan Gavril (bgavrilMS) force-pushed the copilot/fix-4123-message-handler-configuration branch from 5516aec to 15e144c Compare October 30, 2026 11:44
@bgavrilMS
Bogdan Gavril (bgavrilMS) merged commit 311f19f into master Oct 30, 2026
7 checks passed
@bgavrilMS
Bogdan Gavril (bgavrilMS) deleted the copilot/fix-4123-message-handler-configuration branch October 30, 2026 12:02
@bgavrilMS Bogdan Gavril (bgavrilMS) added this to the 4.17.0 milestone Oct 30, 2026
Bogdan Gavril (bgavrilMS) added a commit that referenced this pull request Oct 30, 2026
Preserve the configuration-only overload and regression tests merged in #4124. Retain only warning-level deprecation, migration documentation, and scoped legacy-test suppressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7c2c7e51-63ee-4823-9636-693c8bab1a13
This was referenced Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Simplify AddMicrosoftIdentityMessageHandler configuration overload

4 participants