任何其他字符串都适用于Authorization标头,除了带有“bearer”的任何东西。抛出的异常如下,以及RestTemplate的代码片段
org.springframework.http.HttpHeaders httpHeaders = new org.springframework.http.HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
httpHeaders.set("Authorization", "Bearer a3aae4e7-c612-47ef-be80-9af3d928d553");
httpHeaders.add("Accept", "*/*");
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("display_name", "first.last@example.com");
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, httpHeaders);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, request, String.class);
例外:
org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:66) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
答案 0 :(得分:0)
问题是我的OAuth服务器无法解析持有者令牌,因为它无法从错误的连接字符串连接到数据库。