Не получается сделать Get запрос с proxy-сервера с аутентификатором Java
public String ss() {
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "false");
System.setProperty("jdk.http.auth.proxying.disabledSchemes", "false");
HttpClient client = HttpClient.newBuilder().
proxy(ProxySelector.of(new InetSocketAddress("130.185.126.159", 6774)))
.authenticator(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication () {
return new PasswordAuthentication("host", "pass".toCharArray());
}
}).build();
HttpRequest request = HttpRequest.newBuilder()
.uri(java.net.URI.create("https://mycgsportal.com/MyCGS/CGSAccount/Login"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
return response.headers().toString();
}
В ответе я получаю 407 Proxy Authentication Required; описание к ошибке: " proxy-authenticate=[Basic realm="Invalid proxy credentials or missing IP Authorization."]".