我目前正在评估将Box客户端代码从box-java-sdk-v2更新到最新版本1.0.0,并且看不到将代理添加到BoxAPIConnection的任何方法。

http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxAPIConnection.html

以下是v2 BoxClient的工作方式摘要:

//add a proxy if configured
IBoxRESTClient restClient = new BoxRESTClient() {
        @Override
        public HttpClient getRawHttpClient() {
            HttpHost proxy = new HttpHost(config.getProxyHost(), config.getProxyPort());
            DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
            CloseableHttpClient httpclient = HttpClients.custom()
                    .setRoutePlanner(routePlanner)
                    .build();
            return httpclient;
        }
};

if(config.isUseProxy()){
        logger.info("Configuring Box SDK client to use a proxy: " + config.getProxyHost() + " : " + config.getProxyPort());
        boxClient = new BoxClient(config.getBoxClientToken(), config.getBoxClientSecretToken(), null, null, restClient, (new BoxConfigBuilder()).build());
}else{
        logger.info("Configuring Box SDK client with NO proxy");
        boxClient = new BoxClient(config.getBoxClientToken(), config.getBoxClientSecretToken(), null, null, (new BoxConfigBuilder()).build());
}
// actually do the authentication of our Box client
boxClient.authenticate(boxToken);

最佳答案

BoxAPIConnection中有针对此用例的方法setProxy(),SetProxyUsername()。
尝试改用它们。

07-26 05:41