ExchangeFilterFunctions.basicAuthentication use error [SPR-16955] #21493
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: declined
A suggestion or change that we don't feel we should currently apply
cafebaby opened SPR-16955 and commented
I use the requestFilter in WebClient and use the ExchangeFilterFunctions.basicAuthentication to perform basic authentication as described in the documentation. I use Spring Security's httbasic() to do server security authentication, but the result is still 401 authentication failure.
my code:
WebClient client = WebClient.builder().baseUrl("http://localhost:8081")
.filter(ExchangeFilterFunctions.basicAuthentication("admin", "admin")).build();
Mono<String> result = client.post().uri("/upload")
.syncBody(parts).retrieve()
.onStatus(HttpStatus::is4xxClientError,
response -> Mono
.create(x -> x.success(new Exception("error code:" + response.statusCode().value() + ""))))
.bodyToMono(String.class);
Reference URL: https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-http2
The text was updated successfully, but these errors were encountered: