using Microsoft.IdentityModel.Clients.ActiveDirectory; ... // create a new authentication context AuthenticationContext authCtx = new AuthenticationContext("https://login.microsoftonline.com/[tenant_id]"); try { // attempt to acquire an access token silently AuthenticationResult authResult = await authCtx.AcquireTokenSilentAsync("https://graph.microsoft.com", "[client_id]"); // use the access token to access the resource HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken); HttpResponseMessage response = await httpClient.GetAsync("https://graph.microsoft.com/v1.0/me"); string json = await response.Content.ReadAsStringAsync(); Console.WriteLine(json); } catch (AdalException ex) { // if a silent authentication isn't possible, prompt the user for credentials if (ex.ErrorCode == "failed_to_acquire_token_silently") { AuthenticationResult authResult = await authCtx.AcquireTokenAsync("https://graph.microsoft.com", "[client_id]", new Uri("urn:ietf:wg:oauth:2.0:oob"), new PlatformParameters(PromptBehavior.Auto)); // use the access token to access the resource HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken); HttpResponseMessage response = await httpClient.GetAsync("https://graph.microsoft.com/v1.0/me"); string json = await response.Content.ReadAsStringAsync(); Console.WriteLine(json); } }In this example, the code attempts to acquire an access token silently using the AcquireTokenSilentAsync method. If this fails, the user is prompted for credentials using the AcquireTokenAsync method. The access token is then used to make a request to the Microsoft Graph API to retrieve information about the currently logged-in user. Overall, the Microsoft.IdentityModel.Clients.ActiveDirectory package library provides a robust set of classes for authenticating users using Azure Active Directory, and the AcquireTokenSilentAsync method is a powerful tool for obtaining an access token without prompting the user for credentials unnecessarily.