带有代理的HttpGet授权标头

时间:2015-12-08 22:02:00

标签: http oauth http-get http-proxy bearer-token

我正在使用带有代理设置的HttpGet。该呼叫适用于不需要授权令牌的端点。对于需要令牌的服务,我使用setHeader(),但是看到一个错误,说明了auth令牌丢失。

我错过了什么?

HttpGet get = new HttpGet(endPoint);

get.setHeader("Authorization", token);
HttpHost proxy = new HttpHost("exampleproxy.com",8080);
RequestConfig config = RequestConfig.custom() .setProxy(proxy).build();
get.setConfig(config);

CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();

CloseableHttpResponse response = httpclient.execute(get);

BufferedReader responseReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

0 个答案:

没有答案