spring cloud 如何生成有效但不可用Authorization,请写出完整代码
时间: 2023-02-18 12:07:20 浏览: 87
Spring Cloud Alibaba 集成 Spring Security OAuth2.0 实现认证和授权
可以使用以下代码:
String authorization = Base64.getEncoder().encodeToString("username:password".getBytes());
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Basic " + authorization);
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
ResponseEntity<String> response = restTemplate.exchange("url", HttpMethod.GET, entity, String.class);
阅读全文