Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize basic Authentication header for reactor HttpClient?

I can add the header in a WebClientBuilder like this:

WebClient.builder().baseUrl(...).defaultHeaders(header -> header.setBasicAuth(...)[...].build();

With the HttpClient I'm trying:

HttpClient.create().baseUrl(...).headers(/*not sure how to set the basic authentication here*/)
like image 538
Greg Avatar asked Jul 31 '26 18:07

Greg


1 Answers

Reactor Netty HttpClient does not provide a shortcut for setting this header. You should do it by yourself:

HttpClient.create().baseUrl(...).headers(h -> h.set("Authorization", "Basic " + encodedCredentials))
like image 198
Violeta Georgieva Avatar answered Aug 02 '26 07:08

Violeta Georgieva