private void verifyCredentials(ResultBuilder builder, Map<String, Object> parameters) throws Exception { try { TwitterConfiguration configuration = setProperties(new TwitterConfiguration(), parameters); Twitter twitter = configuration.getTwitter(); twitter.verifyCredentials(); } catch (TwitterException e) { // verifyCredentials throws TwitterException when Twitter service or // network is unavailable or if supplied credential is wrong ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getErrorMessage()) .detail("twitter_error_code", e.getErrorCode()) .detail("twitter_status_code", e.getStatusCode()) .detail("twitter_exception_code", e.getExceptionCode()) .detail("twitter_exception_message", e.getMessage()) .detail("twitter_exception_caused-by-network-issue", e.isCausedByNetworkIssue()) .detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName()) .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e); // For a complete list of error codes see: // https://dev.twitter.com/overview/api/response-codes if (e.getErrorCode() == 89) { errorBuilder.parameterKey("accessToken"); } builder.error(errorBuilder.build()); } } }