Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Akshay Sharma akshay2211

🏠
Working from home
View GitHub Profile
View Oauth Authenticator
/**
* Created by akshay on 28/8/17.
*/
public class TokenAuthenticator implements Authenticator {
private final Context c;
public TokenAuthenticator(Context c) {
this.c = c;
}
@alex-shpak
alex-shpak / Interceptor.java
Last active March 29, 2023 21:06
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
View Interceptor.java
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