Initializing proxy and basic authentication throws 401 unauthorized error and check the logs for the below code gives No credentials for basic schema DEBUG log is seen
proxyUrl = "proxy.ops.org";
proxyport = 8080;
redentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope(proxyUrl, proxyport),
new UsernamePasswordCredentials(username, password)
);
HttpHost myProxy = new HttpHost(proxyUrl, proxyport);
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.setProxy(myProxy).setDefaultCredentialsProvider(credsProvider); clientBuilder.setProxy(myProxy).setDefaultCredentialsProvider(credsProvider);
HttpClient httpClient = clientBuilder.build();
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(httpClient);
RestClient rstCleint = RestClient.builder
.baseUrl("https://test.org")
.requestFactory(factory)
.build();