Skip to content

Commit 01e79b1

Browse files
authored
Stop sending x-app-name and x-app-ver as they are ignored (#5037)
1 parent c06c1e2 commit 01e79b1

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

src/client/Microsoft.Identity.Client/OAuth2/OAuth2Client.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,7 @@ internal void AddBodyParameter(KeyValuePair<string, string> kvp)
221221
private void AddCommonHeaders(RequestContext requestContext)
222222
{
223223
_headers.Add(OAuth2Header.CorrelationId, requestContext.CorrelationId.ToString());
224-
_headers.Add(OAuth2Header.RequestCorrelationIdInResponse, "true");
225-
226-
if (!string.IsNullOrWhiteSpace(requestContext.Logger.ClientName))
227-
{
228-
_headers.Add(OAuth2Header.AppName, requestContext.Logger.ClientName);
229-
}
230-
231-
if (!string.IsNullOrWhiteSpace(requestContext.Logger.ClientVersion))
232-
{
233-
_headers.Add(OAuth2Header.AppVer, requestContext.Logger.ClientVersion);
234-
}
224+
_headers.Add(OAuth2Header.RequestCorrelationIdInResponse, "true");
235225
}
236226

237227
public static T CreateResponse<T>(HttpResponse response, RequestContext requestContext)

tests/Microsoft.Identity.Test.Unit/TelemetryTests/HttpTelemetryTests.cs

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using static Microsoft.Identity.Client.TelemetryCore.Internal.Events.ApiEvent;
3030
using System.Collections.Generic;
3131
using Microsoft.Identity.Client.Internal;
32+
using Microsoft.Identity.Client.OAuth2;
3233

3334
namespace Microsoft.Identity.Test.Unit.TelemetryTests
3435
{
@@ -373,16 +374,16 @@ public async Task CallerSdkDetailsTestAsync()
373374
var cca = CreateConfidentialClientApp();
374375

375376
await cca.AcquireTokenForClient(TestConstants.s_scope)
376-
.WithExtraQueryParameters(new Dictionary<string, string> {
377+
.WithExtraQueryParameters(new Dictionary<string, string> {
377378
{ "caller-sdk-id", "testApiId" },
378379
{ "caller-sdk-ver", "testSdkVersion"} })
379380
.ExecuteAsync().ConfigureAwait(false);
380381

381382
AssertCurrentTelemetry(
382-
requestHandler.ActualRequestMessage,
383-
ApiIds.AcquireTokenForClient,
383+
requestHandler.ActualRequestMessage,
384+
ApiIds.AcquireTokenForClient,
384385
CacheRefreshReason.NoCachedAccessToken,
385-
callerSdkId: "testApiId",
386+
callerSdkId: "testApiId",
386387
callerSdkVersion: "testSdkVersion");
387388
}
388389
}
@@ -429,6 +430,7 @@ public async Task CallerSdkDetailsWithClientNameTestAsync()
429430
.WithClientVersion("testSdkVersion")
430431
.WithAuthority(TestConstants.AuthorityCommonTenant)
431432
.WithHttpManager(_harness.HttpManager)
433+
.WithLogging((a, b, c) => { })
432434
.BuildConcrete();
433435

434436
await cca.AcquireTokenForClient(TestConstants.s_scope)
@@ -443,6 +445,34 @@ await cca.AcquireTokenForClient(TestConstants.s_scope)
443445
}
444446
}
445447

448+
[TestMethod]
449+
public async Task ClientNameVersionNotInHeaders()
450+
{
451+
using (_harness = CreateTestHarness())
452+
{
453+
_harness.HttpManager.AddInstanceDiscoveryMockHandler();
454+
var requestHandler = _harness.HttpManager.AddMockHandlerSuccessfulClientCredentialTokenResponseMessage();
455+
456+
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
457+
.WithClientSecret(TestConstants.ClientSecret)
458+
.WithClientName("testApiId")
459+
.WithClientVersion("testSdkVersion")
460+
.WithAuthority(TestConstants.AuthorityCommonTenant)
461+
.WithHttpManager(_harness.HttpManager)
462+
.WithLogging((a, b, c) => { })
463+
.BuildConcrete();
464+
465+
await cca.AcquireTokenForClient(TestConstants.s_scope)
466+
.ExecuteAsync().ConfigureAwait(false);
467+
468+
requestHandler.ActualRequestHeaders.TryGetValues(OAuth2Header.AppName, out var appName);
469+
requestHandler.ActualRequestHeaders.TryGetValues(OAuth2Header.AppVer, out var appVer);
470+
471+
Assert.IsNull(appName);
472+
Assert.IsNull(appVer);
473+
}
474+
}
475+
446476
[TestMethod]
447477
public async Task CallerSdkDetailsWithNullClientNameTestAsync()
448478
{
@@ -698,8 +728,8 @@ private void AssertCurrentTelemetry(
698728
ApiIds apiId,
699729
CacheRefreshReason cacheInfo,
700730
bool isCacheSerialized = false,
701-
bool isLegacyCacheEnabled = true,
702-
string callerSdkId = "",
731+
bool isLegacyCacheEnabled = true,
732+
string callerSdkId = "",
703733
string callerSdkVersion = "")
704734
{
705735
string[] telemetryCategories = requestMessage.Headers.GetValues(
@@ -727,6 +757,6 @@ private void AssertCurrentTelemetry(
727757
Assert.AreEqual(callerSdkId, telemetryCategories[2].Split(',')[3]);
728758

729759
Assert.AreEqual(callerSdkVersion, telemetryCategories[2].Split(',')[4]);
730-
}
760+
}
731761
}
732762
}

0 commit comments

Comments
 (0)