I would like to implement simple REST client to receive data from the remote endpoint in my Spring project. The remote endpoint is supporting only Digest auth. I have found a solution using netty-http-authenticator. The code can be compiled and in debug view, I can see that the DigestAuthenticator and HttpClient instances are filled with the correct login. But in fact, the authentication is not sent to the server and it responds with 401. I have already tried Firefox as client and simple Flask server on localhost as server. The problem is in my Java client side. Any ideas? This is the code:
DigestAuthenticator digestAuthenticator = new DigestAuthenticator("username", "secretpass!");
HttpClient client = HttpClient.create().doOnRequest((request, connection) -> {
connection.addHandler(new HttpObjectAggregator(1048576));
connection.addHandler(new DigestNettyHttpAuthenticator(digestAuthenticator));
});
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(client);
WebClient spcRestClientPort = WebClient.builder()
//.baseUrl("http://192.168.44.125/spc/")
.baseUrl("http://127.0.0.1:5000/endpoint")
.clientConnector(connector)
.build();
Mono<ResponseEntity<LoginResponseDto>> response = spcRestClientPort.get()
.uri("/output/2/get")
.retrieve()
.toEntity(LoginResponseDto.class);
response.block();