@@ -68,6 +68,11 @@ public async Task<IMicrosoftAuthenticationResult> GetTokenAsync(
68
68
? "OS broker is available and enabled."
69
69
: "OS broker is not available or enabled." ) ;
70
70
71
+ if ( msaPt )
72
+ {
73
+ Context . Trace . WriteLine ( "MSA passthrough is enabled." ) ;
74
+ }
75
+
71
76
try
72
77
{
73
78
// Create the public client application for authentication
@@ -289,17 +294,20 @@ private async Task<AuthenticationResult> GetAccessTokenSilentlyAsync(
289
294
{
290
295
if ( userName is null )
291
296
{
292
- Context . Trace . WriteLine ( "Attempting to acquire token silently for current operating system account..." ) ;
297
+ Context . Trace . WriteLine (
298
+ "Attempting to acquire token silently for current operating system account..." ) ;
293
299
294
- return await app . AcquireTokenSilent ( scopes , PublicClientApplication . OperatingSystemAccount ) . ExecuteAsync ( ) ;
300
+ return await app . AcquireTokenSilent ( scopes , PublicClientApplication . OperatingSystemAccount )
301
+ . ExecuteAsync ( ) ;
295
302
}
296
303
else
297
304
{
298
305
Context . Trace . WriteLine ( $ "Attempting to acquire token silently for user '{ userName } '...") ;
299
306
300
307
// Enumerate all accounts and find the one matching the user name
301
308
IEnumerable < IAccount > accounts = await app . GetAccountsAsync ( ) ;
302
- IAccount account = accounts . FirstOrDefault ( x => StringComparer . OrdinalIgnoreCase . Equals ( x . Username , userName ) ) ;
309
+ IAccount account = accounts . FirstOrDefault ( x =>
310
+ StringComparer . OrdinalIgnoreCase . Equals ( x . Username , userName ) ) ;
303
311
if ( account is null )
304
312
{
305
313
Context . Trace . WriteLine ( $ "No cached account found for user '{ userName } '...") ;
@@ -325,6 +333,12 @@ private async Task<AuthenticationResult> GetAccessTokenSilentlyAsync(
325
333
Context . Trace . WriteLine ( "Failed to acquire token silently; user interaction is required." ) ;
326
334
return null ;
327
335
}
336
+ catch ( Exception ex )
337
+ {
338
+ Context . Trace . WriteLine ( "Failed to acquire token silently." ) ;
339
+ Context . Trace . WriteException ( ex ) ;
340
+ return null ;
341
+ }
328
342
}
329
343
330
344
private async Task < IPublicClientApplication > CreatePublicClientApplicationAsync (
0 commit comments