我尝试通过我们的公司代理调用休息服务,但不断收到响应:
407 Proxy Authentication Required. Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.
任何人都可以建议我可以尝试其他任何方法,或者支持 NTLM 的 RestAssured 替代方案吗?
这是我当前的代码:
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);
最佳答案
这里有几个问题 - 第一个我已经解决了,第二个我仍然被阻止。
设置代理身份验证只需设置正确的 header (如许多其他帖子中所述):
.header("Proxy-Authorization", auth.generateAuthToken())
阻碍我的是我正在调用一个在 https 而不是 http 上运行的服务,并且代理似乎没有被使用......所以回到绘图板。
关于java - 如何使用 Rest-Assured 对来自公司代理后面的休息调用进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33006368/