I have identified two approaches for acquiring token in MSAL for EWS
- Using Username Password approach.
- Using Daemon Confidential approach.
In both above approached after I acquire token, I am not able to refresh it. Though I tried to follow MS docs but no success. GetAccountsAsync() always gives empty result.
Here is my Code for Username Password approach
var publicClientApplication = PublicClientApplicationBuilder.Create(ClientId)
.WithAuthority(AzureCloudInstance.AzurePublic, TenantId).Build();
var accounts = publicClientApplication.GetAccountsAsync().GetAwaiter().GetResult();
var result = publicClientApplication
.AcquireTokenSilent(scopes, accounts.FirstOrDefault())
.ExecuteAsync().GetAwaiter().GetResult();
Can anyone guide me why it is happening so, or is there doc explaining this flow.