Exemplo n.º 1
0
        private static async void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                // Method 1:
                Console.WriteLine(DateTime.Now);
                var token = await AuthenticationService1.GetAccessToken(_app);

                CallApi(token);
                Console.ReadLine();
            }
            catch (HttpRequestException ex)
            {
                Console.WriteLine("\nException Caught!");
                Console.WriteLine("Message :{0} ", ex.Message);
            }
        }
Exemplo n.º 2
0
        public static async Task Main()
        {
            //try
            //{

            //    // Method 1:
            //    var token = await new AuthenticationService1().GetAccessToken();
            //    CallApi(token);
            //    Console.ReadLine();
            //}
            //catch (HttpRequestException e)
            //{
            //    Console.WriteLine("\nException Caught!");
            //    Console.WriteLine("Message :{0} ", e.Message);
            //}
            _app = AuthenticationService1.CreateConfidentialClientApplication();

            Console.WriteLine(DateTime.Now);
            var token = await AuthenticationService1.GetAccessToken(_app);

            CallApi(token);
            Console.ReadLine();
            // StartTimer();
        }