static async Task Main(string[] args) { var config = LoadAppSettings(); var authProvider = new ClientCredentialsAuthProvider(config); //authenticate await GetAccessToken(authProvider); //grab the Graph data await GetDirectoryUsers(authProvider); Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
private static async Task GetAccessToken(ClientCredentialsAuthProvider authProvider) { try { var result = await authProvider.GetAccessTokenAsync(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Auth token acquired :)"); // Console.WriteLine(result); Console.WriteLine(string.Empty); } catch (MsalServiceException ex) when(ex.Message.Contains("AADSTS70011")) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); } Console.ResetColor(); }