Skip to content

Commit 90bc83c

Browse files
authored
6.0 | APIScan | MSAL WithClientName (#3360)
* Backport APIScan changes to v6.0 release branch * Assign builder to builder variable * Assigning builder after With* is not necessary. Internal state of builder is updated.
1 parent 77db4ad commit 90bc83c

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Threading.Tasks;
1111
using Azure.Core;
1212
using Azure.Identity;
13+
using Microsoft.Data.Common;
1314
using Microsoft.Extensions.Caching.Memory;
1415
using Microsoft.Identity.Client;
1516
using Microsoft.Identity.Client.Extensibility;
@@ -542,31 +543,24 @@ private static bool AreEqual(byte[] a1, byte[] a2)
542543

543544
private IPublicClientApplication CreateClientAppInstance(PublicClientAppKey publicClientAppKey)
544545
{
545-
IPublicClientApplication publicClientApplication;
546-
547-
#if NETFRAMEWORK
548-
if (_iWin32WindowFunc != null)
549-
{
550-
publicClientApplication = PublicClientApplicationBuilder.Create(publicClientAppKey._applicationClientId)
551-
.WithAuthority(publicClientAppKey._authority)
552-
.WithClientName(Common.DbConnectionStringDefaults.ApplicationName)
553-
.WithClientVersion(Common.ADP.GetAssemblyVersion().ToString())
554-
.WithRedirectUri(publicClientAppKey._redirectUri)
555-
.WithParentActivityOrWindow(_iWin32WindowFunc)
556-
.Build();
557-
}
558-
else
559-
#endif
546+
PublicClientApplicationBuilder builder = PublicClientApplicationBuilder
547+
.CreateWithApplicationOptions(new PublicClientApplicationOptions
548+
{
549+
ClientId = publicClientAppKey._applicationClientId,
550+
ClientName = DbConnectionStringDefaults.ApplicationName,
551+
ClientVersion = ADP.GetAssemblyVersion().ToString(),
552+
RedirectUri = publicClientAppKey._redirectUri,
553+
})
554+
.WithAuthority(publicClientAppKey._authority);
555+
556+
#if NETFRAMEWORK
557+
if (_iWin32WindowFunc is not null)
560558
{
561-
publicClientApplication = PublicClientApplicationBuilder.Create(publicClientAppKey._applicationClientId)
562-
.WithAuthority(publicClientAppKey._authority)
563-
.WithClientName(Common.DbConnectionStringDefaults.ApplicationName)
564-
.WithClientVersion(Common.ADP.GetAssemblyVersion().ToString())
565-
.WithRedirectUri(publicClientAppKey._redirectUri)
566-
.Build();
559+
builder.WithParentActivityOrWindow(_iWin32WindowFunc);
567560
}
561+
#endif
568562

569-
return publicClientApplication;
563+
return builder.Build();
570564
}
571565

572566
private static TokenCredentialData CreateTokenCredentialInstance(TokenCredentialKey tokenCredentialKey, string secret)

0 commit comments

Comments
 (0)