I am using OkHttp
in my android application with several async requests. All requests require a token to be sent with the header. Sometimes I need to refresh th
Add synchronized to authenticate() method signature.
And make sure getToken() method is blocking.
@Nullable
@Override
public synchronized Request authenticate(Route route, Response response) {
String newAccessToken = getToken();
return response.request().newBuilder()
.header("Authorization", "Bearer " + newAccessToken)
.build();
}