Using SDK with a proxy

Hi,

I am having a problem when trying to use the SDK behind a proxy with authentication. I can set up the java.net.Proxy when creating the ApiClient, and works IF I previously introduce the credentials via web browser. I have also tested to create a default Authenticator for use it in every request, which hasn´t work with the API requests directly, but if I open a new connection with google for example, it will use the authenticator and then the ApiClient starts working.

Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
String user = System.getProperty("http.proxyUser", PROXY_USER);
String password = System.getProperty("http.proxyPassword", PROXY_PASSWORD);
return new PasswordAuthentication(user, password.toCharArray());

			}

Which is the proper way to pass the credentials to the ApiClient?

https://developer.mypurecloud.com/api/rest/client-libraries/java/index.html#authenticating

Also, see the withProxy(Proxy proxy) method in the API Client's builder.

Hi Tim,

Thats not the point. We are using the withProxy option while creating the apiClient, but the problem is that the Proxy does not authenticate automatically using the authenticator described previously. The question is how can we pass the PROXY CREDENTIALS to the ApiClient, not the client id and secret.

Thanks

The Java SDK doesn't directly support authenticated proxies. I've created an issue )(API-4527) to investigate adding the feature. In the meantime, you can work around this by implementing your own HTTP connector. The easiest thing to do would be to create a copy of the default connector you're using and modify it to suit your needs. If you come up with a solution and want to share it here, that will help advance the issue to add authenticated proxy support.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.