Skip to content

Instantly share code, notes, and snippets.

View thvranken's full-sized avatar

Thomas Vranken thvranken

View GitHub Profile
@thvranken
thvranken / Interceptor.java
Created April 1, 2016 16:16 — 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