private static int PollForResponse(IServiceClient serviceClient, AuthorizationRequest authorizationRequest) { try { Console.Write("Checking for response"); while (true) { Console.Write("."); var authResponse = serviceClient.GetAuthorizationResponse(authorizationRequest.Id); if (authResponse != null) { PrintAuthorizationResponse(authResponse); return(0); } // if not, we are still waiting on the user. wait a bit ... Thread.Sleep(1000); } } catch (AuthorizationRequestTimedOutError) { Console.WriteLine("User did not reply before the Authorization request expired."); } catch (AuthorizationRequestCanceled) { Console.WriteLine($"Authorization request was canceled."); } catch (BaseException e) { Console.WriteLine($"Error while retrievieng authorization request {authorizationRequest.Id}. Error: {e.Message}"); } return(1); }