Simplifies the flow of regenerating expired JWT tokens.
client.setUser(user, listener -> {
OkHttpClient httpClient = new OkHttpClient()
.newBuilder()
.build();
// request the token for this user
Request request = new Request.Builder()
.url("https://path/to/my/backend/")
.header("Authorization", "user-session-id")
.build();
httpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
// the request to get the token failed
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
Log.w(TAG, "getting the token worked!");
listener.onSuccess(response.body.string());
}
});
}
);