I have post request like below, Cant we make it automatic like Retrofit 2.0 interceptor if access token expires get refresh token and service call continues? without interruption?
URL url = new URL(myurl + "?access_token=" + access_token);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(100000000 /* milliseconds */);
conn.setConnectTimeout(150000000 /* milliseconds */);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
conn.setRequestProperty("charset", "utf-8");
conn.setDoInput(true);
conn.connect();
Is there any method to do this automatically when we get 401 response code ?
As far as i know, No way is provided for this in any framework as this is purely requirement based. You will have to post SERIAL calls as stated below :
Hope it helps a bit.