Posts

Showing posts with the label retrofit2

Why Retrofit Authenticator does not refresh token?

Why Retrofit Authenticator does not refresh token? I am building an app with Retrofit , Dagger etc. and using Authenticator to refresh the token. I have set the token expiry time to 1 minute just to see if the Authenticator is triggered and it's not. Below is my Authenticator implementation public class TokenAuthenticator implements Authenticator { private ServiceManagerHolder serviceHolder; @Inject public TokenAuthenticator(@NonNull ServiceManagerHolder serviceHolder) { this.serviceHolder=serviceHolder; } @Nullable @Override public Request authenticate(Route route, Response response) throws IOException { if(serviceHolder.serviceManager() ==null) { return null; } if(response.code()==401) { Request request = response.request(); serviceHolder.serviceManager().refreshAccessToken(GRANT_TYPE_REFRESH, KikoConstants.AUTH_TOKEN_TIMEOUT, ANDROID_CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN) ...