Skip to content

Instantly share code, notes, and snippets.

View CarolusX74's full-sized avatar
💭
Lerning

Carlos Javier Torres Pensa CarolusX74

💭
Lerning
View GitHub Profile
@CarolusX74
CarolusX74 / Interceptor.java
Created June 26, 2017 23:03 — 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