Skip to content

Instantly share code, notes, and snippets.

View alexander-mironov's full-sized avatar

Alexander Mironov alexander-mironov

View GitHub Profile
@alexander-mironov
alexander-mironov / Interceptor.java
Created March 17, 2020 17:55 — forked from alex-shpak/Interceptor.java
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON