I'm trying to call a rest service via our corporate proxy but keep getting the response:
407 Proxy Authentication Required. Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.
Can anyone suggest anything else I can try, or an alternative to RestAssured that supports NTLM?
This is my current code:
PreemptiveBasicAuthScheme auth = new PreemptiveBasicAuthScheme();
auth.setUserName("my username");
auth.setPassword("my password");
// was getting desperate so tried adding this
System.setProperty("http.proxyHost", "XXXX");
System.setProperty("http.proxyPort", "8080");
System.setProperty("http.proxyUser", "my username");
System.setProperty("http.proxyPassword", "my password");
System.setProperty("https.proxyHost", "XXXX");
System.setProperty("https.proxyPort", "8080");
System.setProperty("https.proxyUser", "my username");
System.setProperty("https.proxyPassword", "my password");
Response r = RestAssured
.given()
// tried with and without this
.header("Proxy-Authorization", auth.generateAuthToken())
.proxy("XXXX", 8080)
.get(fullPath, key, key);
|
我试图通过我们的公司代理调用REST服务,但继续得到响应:
407 Proxy Authentication Required. Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.
任何人都可以建议什么我可以试试,或替代放心下来,支持NTLM身份验证?
这是我目前的代码:
PreemptiveBasicAuthScheme auth = new PreemptiveBasicAuthScheme();
auth.setUserName("my username");
auth.setPassword("my password");
// was getting desperate so tried adding this
System.setProperty("http.proxyHost", "XXXX");
System.setProperty("http.proxyPort", "8080");
System.setProperty("http.proxyUser", "my username");
System.setProperty("http.proxyPassword", "my password");
System.setProperty("https.proxyHost", "XXXX");
System.setProperty("https.proxyPort", "8080");
System.setProperty("https.proxyUser", "my username");
System.setProperty("https.proxyPassword", "my password");
Response r = RestAssured
.given()
// tried with and without this
.header("Proxy-Authorization", auth.generateAuthToken())
.proxy("XXXX", 8080)
.get(fullPath, key, key);
|
There were a couple of issues here - the first I've sorted, the second I'm still blocked on.
Setting the proxy authentication was a simple matter of setting the correct header (as has been noted in many other posts):
.header("Proxy-Authorization", auth.generateAuthToken())
What was blocking me was that I'm calling a service running on https rather than http and the proxy does not appear to be used... so back to the drawing board. |
这里有几个问题-第一个我已经排序,第二我仍然封锁。
设置代理身份验证是一个简单的问题,设置正确的头(如已注意到许多其他职位):
.header("Proxy-Authorization", auth.generateAuthToken())
是什么阻止我,我叫服务上运行的HTTPS而不是HTTP和代理似乎没有用…所以回到绘图板。 |