private void FetchNewToken()
        {
            var response = _authenticationEndpoint.Execute <Office365AuthenticationToken>(_authenticationRequest);

            if (response.IsSuccessful && response.Data != null)
            {
                _office365AuthenticationResponse = response.Data;
            }
            else
            {
                if (response.ErrorException != null)
                {
                    throw response.ErrorException;
                }

                if (!string.IsNullOrWhiteSpace(response.ErrorMessage))
                {
                    throw new AuthenticationException(response.ErrorMessage);
                }

                if (!string.IsNullOrWhiteSpace(response.Content))
                {
                    throw new AuthenticationException(response.Content);
                }

                throw new AuthenticationException("Could not authenticate");
            }
        }
 public Office365Authenticator(string clientId, string clientSecret)
 {
     _authenticationEndpoint          = CreateAuthenticationEndpoint();
     _authenticationRequest           = CreateAuthenticationRequest(clientId, clientSecret);
     _office365AuthenticationResponse = new Office365AuthenticationToken();
 }