Java 如何使用spring社交rest模板交换方法忽略OAuth2RequestInterceptor API请求头格式 我的自定义客户端http请求拦截器 使用 服务器接收到请求头格式

Java 如何使用spring社交rest模板交换方法忽略OAuth2RequestInterceptor API请求头格式 我的自定义客户端http请求拦截器 使用 服务器接收到请求头格式,java,spring,resttemplate,spring-social,Java,Spring,Resttemplate,Spring Social,我如何解决这个问题?你为什么要用这个?setInterceptors(Arrays.asList(新ClientHttpRequestInterceptor[]{new AdminKeyHeaderAuth2RequestInterceptor()}));我认为可以通过替换拦截器列表来解决这个问题。(对不起,我的英语很差)哦,对不起,我误解了你的评论。这是错误的源代码。类MyInterceptor->类AdminKeyHeaderAuth2RequestInterceptor(在第二个代码块中)

我如何解决这个问题?

你为什么要用这个?setInterceptors(Arrays.asList(新ClientHttpRequestInterceptor[]{new AdminKeyHeaderAuth2RequestInterceptor()}));我认为可以通过替换拦截器列表来解决这个问题。(对不起,我的英语很差)哦,对不起,我误解了你的评论。这是错误的源代码。类MyInterceptor->类AdminKeyHeaderAuth2RequestInterceptor(在第二个代码块中)
.....
Authorization: KakaoAK {token}
.....
class AdminKeyHeaderOAuth2RequestInterceptor implements ClientHttpRequestInterceptor {
    @Override
    public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, ClientHttpRequestExecution execution) throws IOException {
        return execution.execute(protectedResourceRequest, body);
    }
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
headers.setAccept(Arrays.asList(new MediaType[]{MediaType.ALL}));
headers.set("Authorization", "KakaoAK " + adminKey); //admin key를 header에 셋팅해야함

MultiValueMap<String, String> param = new LinkedMultiValueMap<String, String>();
param.set("limit", limit);
param.set("fromId", fromId);
param.set("order", order);

restTemplate.setInterceptors(Arrays.asList(new ClientHttpRequestInterceptor[]{new AdminKeyHeaderOAuth2RequestInterceptor()}));

ResponseEntity<KakaoIds> response = restTemplate.exchange(buildApiUri("/v1/user/ids", param).toString(), HttpMethod.GET, new HttpEntity<Object>(headers), KakaoIds.class);
HttpRequest protectedResourceRequest = new HttpRequestDecorator(request);
protectedResourceRequest.getHeaders().set("Authorization", oauth2Version.getAuthorizationHeaderValue(accessToken));
return execution.execute(protectedResourceRequest, body);
....
Authorization: Bearer {token}
....