【发布时间】:2017-12-22 04:50:18
【问题描述】:
我知道有关于这个主题的现有讨论,但我无法找到我的情况的答案:我想直接通过 URL 传递凭据(遵循 https://user:pass@url 方案)。我收到此代码的 401 错误:
final RestTemplate restTemplate = new RestTemplate();
final ResponseEntity<String> wsCalendarResponse = restTemplate.getForEntity("https://user:pass@foobarbaz.com", String.class);
如果我在浏览器中复制.粘贴完全相同的 URL (https://user:pass@foobarbaz.com),它可以正常工作。
任何线索,比这个答案更简单:Basic authentication for REST API using spring restTemplate?
谢谢
【问题讨论】:
-
答案有帮助吗?因为 RestTemplate 和身份验证仍然存在一些问题,Apache 客户端无法立即解决。
标签: java spring authentication resttemplate