static async Task Main(string[] args) { var config = LoadAppSettings(); var authProvider = new ClientCredentialsAuthProvider(config); //authenticate await GetAccessToken(authProvider); await MakeRequest(config); Console.WriteLine("Done!"); }
private static async Task GetAccessToken(ClientCredentialsAuthProvider authProvider) { try { _token = await authProvider.GetAccessTokenAsync(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Auth token acquired :)"); Console.WriteLine(_token); Console.WriteLine(string.Empty); } catch (MsalServiceException ex) when(ex.Message.Contains("AADSTS70011")) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); } Console.ResetColor(); }