@Test public void shouldRefreshSecondTimeIfWeReceivedTheSameRefreshTokenTheFirstTime() throws Exception { final OAuthRefreshTokenProcessor processor = createProcessor( "{\"access_token\": \"new-access-token\", \"refresh_token\": \"new-refresh-token\"}", "{\"access_token\": \"newer-access-token\", \"refresh_token\": \"new-refresh-token\"}"); assertThatThrownBy(() -> processor.process(exchange)).isSameAs(exception); assertThat(processor.state.getAccessToken()).isEqualTo("new-access-token"); assertThat(processor.state.getRefreshToken()).isEqualTo("new-refresh-token"); assertThatThrownBy(() -> processor.process(exchange)).isSameAs(exception); assertThat(processor.state.getAccessToken()).isEqualTo("newer-access-token"); assertThat(processor.state.getRefreshToken()).isEqualTo("new-refresh-token"); }
@Override public void process(final Exchange exchange) throws Exception { final Exception caught = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); if (caught instanceof HttpOperationFailedException) { final HttpOperationFailedException httpFailure = (HttpOperationFailedException) caught; LOG.warn("Failed invoking the remote API, status: {} {}, response body: {}", httpFailure.getStatusCode(), httpFailure.getStatusText(), httpFailure.getResponseBody()); if (!shouldTryRefreshingAccessCode(httpFailure)) { throw httpFailure; } tryToRefreshAccessToken(); throw httpFailure; } super.process(exchange); }
OAuthRefreshTokenOnFailProcessor extends OAuthRefreshTokenProcessor { @Override public void process(final Exchange exchange) throws Exception { final Exception caught = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); if (caught instanceof HttpOperationFailedException) { final HttpOperationFailedException httpFailure = (HttpOperationFailedException) caught; LOG.warn("Failed invoking the remote API, status: {} {}, response body: {}", httpFailure.getStatusCode(), httpFailure.getStatusText(), httpFailure.getResponseBody()); if (!shouldTryRefreshingAccessCode(httpFailure)) { throw httpFailure; } tryToRefreshAccessToken(); throw httpFailure; } super.process(exchange); } }
OAuthRefreshTokenOnFailProcessor extends OAuthRefreshTokenProcessor { @Override public void process(final Exchange exchange) throws Exception { final Exception caught = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); if (caught instanceof HttpOperationFailedException) { final HttpOperationFailedException httpFailure = (HttpOperationFailedException) caught; LOG.warn("Failed invoking the remote API, status: {} {}, response body: {}", httpFailure.getStatusCode(), httpFailure.getStatusText(), httpFailure.getResponseBody()); if (!shouldTryRefreshingAccessCode(httpFailure)) { throw httpFailure; } tryToRefreshAccessToken(); throw httpFailure; } super.process(exchange); } OAuthRefreshTokenOnFailProcessor(final OAuthState state, final Configuration configuration); }
OAuthRefreshTokenOnFailProcessor extends OAuthRefreshTokenProcessor { @Override public void process(final Exchange exchange) throws Exception { final Exception caught = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); if (caught instanceof HttpOperationFailedException) { final HttpOperationFailedException httpFailure = (HttpOperationFailedException) caught; LOG.warn("Failed invoking the remote API, status: {} {}, response body: {}", httpFailure.getStatusCode(), httpFailure.getStatusText(), httpFailure.getResponseBody()); if (!shouldTryRefreshingAccessCode(httpFailure)) { throw httpFailure; } tryToRefreshAccessToken(); throw httpFailure; } super.process(exchange); } OAuthRefreshTokenOnFailProcessor(final OAuthState state, final Configuration configuration); @Override void process(final Exchange exchange); }
OAuthRefreshTokenOnFailProcessor extends OAuthRefreshTokenProcessor { @Override public void process(final Exchange exchange) throws Exception { final Exception caught = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); if (caught instanceof HttpOperationFailedException) { final HttpOperationFailedException httpFailure = (HttpOperationFailedException) caught; LOG.warn("Failed invoking the remote API, status: {} {}, response body: {}", httpFailure.getStatusCode(), httpFailure.getStatusText(), httpFailure.getResponseBody()); if (!shouldTryRefreshingAccessCode(httpFailure)) { throw httpFailure; } tryToRefreshAccessToken(); throw httpFailure; } super.process(exchange); } OAuthRefreshTokenOnFailProcessor(final OAuthState state, final Configuration configuration); @Override void process(final Exchange exchange);  }