I'm getting the following error when trying to use a cached token. I'm using the list that was provided as an example here: https://learn.microsoft.com/bs-latn-ba/azure/active-directory/develop/msal-net-acquire-token-silently
cannot convert from 'System.Collections.Generic.IEnumerable' to 'Microsoft.Identity.Client.IAccount'`
static async Task<GraphServiceClient> Auth()
{
var clientApp = PublicClientApplicationBuilder.Create(ConfigurationManager.AppSettings["clientId"]).Build();
string[] scopes = new string[] { "user.read" };
string token = null;
var app = PublicClientApplicationBuilder.Create(ConfigurationManager.AppSettings["clientId"]).Build();
AuthenticationResult result = null;
var accounts = await app.GetAccountsAsync();
result = await app.AcquireTokenSilent(scopes, accounts)
.ExecuteAsync();
token = result.AccessToken;
GraphServiceClient graphClient = new GraphServiceClient(
"https://graph.microsoft.com/v1.0",
new DelegateAuthenticationProvider(
async (requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", token);
}));
return graphClient;
}