Closed
Description
So to add basic authentication on every request sent add the BasicAuthIntercept like below:
Example
Where the username is rob
and the password is bot
... create and register the BasicAuthIntercept like:
public static HttpClientContext client() {
BasicAuthIntercept basicAuthIntercept = new BasicAuthIntercept("rob", "bot")
return HttpClientContext.newBuilder()
.withBaseUrl(baseUrl)
.withRequestListener(new RequestLogger())
.withBodyAdapter(new JacksonBodyAdapter(new ObjectMapper()))
.withRequestIntercept(basicAuthIntercept) <!-- HERE !!!
.build();
}