Account attentions.

This commit is contained in:
Burak Kaan Köse
2025-11-14 12:12:13 +01:00
parent 6be271565e
commit 13cb3a1042
11 changed files with 70 additions and 42 deletions
@@ -90,6 +90,8 @@ public class OutlookAuthenticator : BaseAuthenticator, IOutlookAuthenticator
try
{
throw new MsalUiRequiredException("test", "test2");
var authResult = await _publicClientApplication.AcquireTokenSilent(Scope, storedAccount).ExecuteAsync();
return new TokenInformationEx(authResult.AccessToken, authResult.Account.Username);
@@ -113,6 +115,12 @@ public class OutlookAuthenticator : BaseAuthenticator, IOutlookAuthenticator
{
await EnsureTokenCacheAttachedAsync();
// Interactive authentication required but window doesn't exist.
// This can happen when being called from a notification background task and the token is expired.
// Force account attention;
if (_nativeAppService.GetCoreWindowHwnd == null) throw new AuthenticationAttentionException(account);
AuthenticationResult authResult = await _publicClientApplication
.AcquireTokenInteractive(Scope)
.ExecuteAsync();