@@ -552,45 +552,30 @@ private static bool AreEqual(byte[] a1, byte[] a2)
552
552
553
553
private IPublicClientApplication CreateClientAppInstance ( PublicClientAppKey publicClientAppKey )
554
554
{
555
- IPublicClientApplication publicClientApplication ;
556
-
557
- #if NETSTANDARD
558
- if ( _parentActivityOrWindowFunc != null )
559
- {
560
- publicClientApplication = PublicClientApplicationBuilder . Create ( publicClientAppKey . _applicationClientId )
561
- . WithAuthority ( publicClientAppKey . _authority )
562
- . WithClientName ( Common . DbConnectionStringDefaults . ApplicationName )
563
- . WithClientVersion ( Common . ADP . GetAssemblyVersion ( ) . ToString ( ) )
564
- . WithRedirectUri ( publicClientAppKey . _redirectUri )
565
- . WithParentActivityOrWindow ( _parentActivityOrWindowFunc )
566
- . Build ( ) ;
567
- }
568
- #endif
569
- #if NETFRAMEWORK
570
- if ( _iWin32WindowFunc != null )
555
+ PublicClientApplicationBuilder builder = PublicClientApplicationBuilder
556
+ . CreateWithApplicationOptions ( new PublicClientApplicationOptions
557
+ {
558
+ ClientId = publicClientAppKey . _applicationClientId ,
559
+ ClientName = Common . DbConnectionStringDefaults . ApplicationName ,
560
+ ClientVersion = Common . ADP . GetAssemblyVersion ( ) . ToString ( ) ,
561
+ RedirectUri = publicClientAppKey . _redirectUri ,
562
+ } )
563
+ . WithAuthority ( publicClientAppKey . _authority ) ;
564
+
565
+ #if NETFRAMEWORK
566
+ if ( _iWin32WindowFunc is not null )
571
567
{
572
- publicClientApplication = PublicClientApplicationBuilder . Create ( publicClientAppKey . _applicationClientId )
573
- . WithAuthority ( publicClientAppKey . _authority )
574
- . WithClientName ( Common . DbConnectionStringDefaults . ApplicationName )
575
- . WithClientVersion ( Common . ADP . GetAssemblyVersion ( ) . ToString ( ) )
576
- . WithRedirectUri ( publicClientAppKey . _redirectUri )
577
- . WithParentActivityOrWindow ( _iWin32WindowFunc )
578
- . Build ( ) ;
568
+ builder . WithParentActivityOrWindow ( _iWin32WindowFunc ) ;
579
569
}
580
- #endif
581
- #if ! NETCOREAPP
582
- else
583
- #endif
570
+ #endif
571
+ #if NETSTANDARD
572
+ if ( _parentActivityOrWindowFunc is not null )
584
573
{
585
- publicClientApplication = PublicClientApplicationBuilder . Create ( publicClientAppKey . _applicationClientId )
586
- . WithAuthority ( publicClientAppKey . _authority )
587
- . WithClientName ( Common . DbConnectionStringDefaults . ApplicationName )
588
- . WithClientVersion ( Common . ADP . GetAssemblyVersion ( ) . ToString ( ) )
589
- . WithRedirectUri ( publicClientAppKey . _redirectUri )
590
- . Build ( ) ;
574
+ builder . WithParentActivityOrWindow ( _parentActivityOrWindowFunc ) ;
591
575
}
576
+ #endif
592
577
593
- return publicClientApplication ;
578
+ return builder . Build ( ) ;
594
579
}
595
580
596
581
private static TokenCredentialData CreateTokenCredentialInstance ( TokenCredentialKey tokenCredentialKey , string secret )
@@ -645,7 +630,7 @@ private static TokenCredentialData CreateTokenCredentialInstance(TokenCredential
645
630
// This should never be reached, but if it is, throw an exception that will be noticed during development
646
631
throw new ArgumentException ( nameof ( ActiveDirectoryAuthenticationProvider ) ) ;
647
632
}
648
-
633
+
649
634
internal class PublicClientAppKey
650
635
{
651
636
public readonly string _authority ;
0 commit comments