[Bug] WithClientName doesn't send the x-app-header unless WithLogging is called. #4979
Labels
confidential-client
needs attention
Delete label after triage
untriaged
Do not delete. Needed for Automation
Library version used
4.65.0
.NET version
NET8.0, but can repro in NET6, NET472, and NET48
Scenario
ConfidentialClient - service to service (AcquireTokenForClient)
Is this a new or an existing app?
This is a new app or experiment
Issue description and reproduction steps
Onboarding to use MSI from within my RP. A recommendation from MIRP team is to use
.WithClientName("MSI.<RP namespace>")
. Using a custom HttpClientFactory, I can see that the request doesn't containx-app-name
header as documented. I can send my own headers in the token request as a workaround, so it's not a huge deal.However, looking into it further, it appears that the header is dependent on the logger:
microsoft-authentication-library-for-dotnet/src/client/Microsoft.Identity.Client/OAuth2/OAuth2Client.cs
Line 228 in ac1cb05
.WithLogging(NullIdentityModelLogger.Instance)
fixes the issue, and the request to the authority has the header properly populated.This seems like a bug. It's certainly unexpected behavior.
Relevant code snippets
Expected behavior
Setting .WithClientName() on the builder should ensure that the client name is sent, regardless of any other calls.
Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
Regression
No response
Solution and workarounds
Later in each actual request using the
AcquireTokenForClientParameterBuilder
call.WithExtraHttpHeaders
and setx-app-name
to the value.The text was updated successfully, but these errors were encountered: