The project work with OAuth2 protocol. But there is token in request body, not in header. So I couldn't find a way send request again with new token. Flow: request -> fail -> refresh token -> request
Request exp:
{"request": "asd",
"token":"...",
"request_data":{} }
I'm sending same request with same token when error occurs, as follows:
requestExp().flatMap(resource -> {
return Single.just(new Object());
}).retryWhen(th-> {
AtomicInteger counter = new AtomicInteger();
return th.takeWhile(e -> {
if (Objects.equals(e.getMessage(), "test")) {
return counter.getAndIncrement() != 1;
}
});
});
Any help?