I need to use OkHttp3 in java as a HTTP client and send Authorization header in request.
example:
Authorization: Bearer eyJ0eXA
The above answer lead to correct path but need some changes.
private Response requestBuilderWithBearerToken(String userToken) throws IOException {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(YourURL)
.get()
.addHeader("cache-control", "no-cache")
.addHeader("Authorization" , "Bearer " + userToken)
.build();
return client.newCall(request).execute();