private HttpResponse execute(HttpRequest request, int... allowedErrorCodes) throws IOException,
UnAuthorizedAccessTokenException {
HttpResponse response = HttpRequests.execute(request, defaultConfig);
int responseCode = response.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new UnAuthorizedAccessTokenException("Unauthorized status code received from the server.");
} else if (!isSuccessful(responseCode) && !ArrayUtils.contains(allowedErrorCodes, responseCode)) {
throw new IOException(responseCode + ": " + response.getResponseBodyAsString());
}
return response;
}