Problem Statement:
I'm using Retrofit in my application for API calls. Currently I've 20+ Retrofit Interfaces, with different Callbacks
. Currently when app receives INVALID_SESSION_ID
in anyone of these Interfaces (say UpdateUserAPI
), I've to get new ACCESS_TOKEN
, by invoking AccessTokenAPI
.
Approach Suggested:
When app receives INVALID_SESSION_ID
in Callback
in UpdateUserAPI
, invoke AccessTokenAPI
to get new ACCESS_TOKEN
. Upon receiving new ACCESS_TOKEN
, post the actual call (with initial parameters in UpdateUserAPI
) with new ACCESS_TOKEN
. But this requires to save parameters in the class which implements UpdateUserAPI
. Also I need to retry getting ACCESS_TOKEN
only once, which should be handled.
What is the best approach to implement above requirement?