public static bool CreateGraphClient() { try { //********************************************************************* // setup Microsoft Graph Client for delegated user. //********************************************************************* client = AuthenticationHelper.GetAuthenticatedClientForUser(); return(true); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Acquiring a token failed with the following error: {0}", ex.Message); if (ex.InnerException != null) { //You should implement retry and back-off logic per the guidance given here:http://msdn.microsoft.com/en-us/library/dn168916.aspx //InnerException Message will contain the HTTP error status codes mentioned in the link above Console.WriteLine("Error detail: {0}", ex.InnerException.Message); } Console.ResetColor(); Console.ReadKey(); return(false); } }
public static bool CreateGraphClient() { try { //********************************************************************* // setup Microsoft Graph Client for delegated user. //********************************************************************* if (Constants.ClientIdForUserAuthn != "ENTER_YOUR_CLIENT_ID") { client = AuthenticationHelper.GetAuthenticatedClientForUser(); return(true); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("You haven't configured a value for ClientIdForUserAuthn in Constants.cs. Please follow the Readme instructions for configuring this application."); Console.ResetColor(); Console.ReadKey(); return(false); } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Acquiring a token failed with the following error: {0}", ex.Message); if (ex.InnerException != null) { //You should implement retry and back-off logic per the guidance given here:http://msdn.microsoft.com/en-us/library/dn168916.aspx //InnerException Message will contain the HTTP error status codes mentioned in the link above Console.WriteLine("Error detail: {0}", ex.InnerException.Message); } Console.ResetColor(); Console.ReadKey(); return(false); } }