I am trying to implement the token based authentication with access and refresh token. The access token expires after some limited time. Then using the refresh token it needs to be updated again. I am following this reference and this answer as well. As I am new to android I got no idea about how to implement these concepts.
This is my interface to get access token using the refresh token.
//get access Token with Refresh Token
@POST("/api/token")
Call<ResponseBody> getAccessToken(@Body JSONObject jsonObject);
This is my Retrofit Client:
public class ApiClient {
public static final String BASE_URL = "https://lit-cove-70675.herokuapp.com";
private static Retrofit retrofit = null;
public static Retrofit getClient() {
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}
I have no idea where and how to implement those Service Generators
and Authenticator
. I have to pass "Authentication"=>ACCESSTOKEN
in header with every API URL.