Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ private Dictionary<string, string> GetBodyParameters()
var dict = new Dictionary<string, string>
{
[OAuth2Parameter.GrantType] = OAuth2GrantType.ClientCredentials,
[OAuth2Parameter.Scope] = AuthenticationRequestParameters.Scope.AsSingleString()
[OAuth2Parameter.Scope] = AuthenticationRequestParameters.Scope.AsSingleString(),
[OAuth2Parameter.ClientInfo] = "2"
};

return dict;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using static Microsoft.Identity.Client.Internal.JsonWebToken;
using Microsoft.Identity.Client.RP;
using Microsoft.Identity.Client.Http;
using Microsoft.Identity.Client.OAuth2;

namespace Microsoft.Identity.Test.Unit
{
Expand Down Expand Up @@ -1019,6 +1020,43 @@ public void EnsureNullCertDoesNotSetSerialNumberTestAsync()
}
}

[TestMethod]
public async Task AcquireTokenForClient_ShouldSendClientInfoParameter_WithValueTwo_Async()
{
// Arrange
using (var httpManager = new MockHttpManager())
{
httpManager.AddInstanceDiscoveryMockHandler();

// Set up the expected POST data to include client_info = "2"
var expectedPostData = new Dictionary<string, string>
{
[OAuth2Parameter.GrantType] = OAuth2GrantType.ClientCredentials,
[OAuth2Parameter.Scope] = TestConstants.s_scope.AsSingleString(),
[OAuth2Parameter.ClientInfo] = "2"
};

var handler = httpManager.AddMockHandlerSuccessfulClientCredentialTokenResponseMessage(
expectedPostData: expectedPostData);

var app = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithClientSecret(TestConstants.ClientSecret)
.WithAuthority(TestConstants.AuthorityCommonTenant)
.WithHttpManager(httpManager)
.BuildConcrete();

// Act
var result = await app.AcquireTokenForClient(TestConstants.s_scope)
.ExecuteAsync()
.ConfigureAwait(false);

// Assert
Assert.IsNotNull(result);
Assert.AreEqual(TokenSource.IdentityProvider, result.AuthenticationResultMetadata.TokenSource);
}
}

private void BeforeCacheAccess(TokenCacheNotificationArgs args)
{
args.TokenCache.DeserializeMsalV3(_serializedCache);
Expand Down