Spring Boot Callable — 401 Несанкционированный: [нет тела]JAVA

Программисты JAVA общаются здесь
Anonymous
Spring Boot Callable — 401 Несанкционированный: [нет тела]

Сообщение Anonymous »

Я использую интерфейс Callable внутри приложения Spring Boot, которое отправляет запрос аутентификации:

Код: Выделить всё

public class TestCallable implements Callable {

TestEntity testEntity;

public TestCallable(TestEntity testEntity) {
this.testEntity = testEntity;
}

@Override
public TestDto call() throws Exception {
String authRequestBody = "{" +
"\"username\": \"" + testEntity.getLogin() + "\"," +
"\"password\": \"" + testEntity.getPassword() + "\"," +
"\"client_id\": \"" + testEntity.getClientId() + "\"," +
"\"client_secret\": \"" + testEntity.getClientSecret() + "\"" +
"}";
HttpHeaders authHeaders = new HttpHeaders();
authHeaders.setContentType(MediaType.APPLICATION_JSON);
authHeaders.set("Accept", "application/json");
authHeaders.set("Grant_type", "password");
HttpEntity authEntity = new HttpEntity(authRequestBody, authHeaders);
RestTemplate restTemplate = new RestTemplate();
TestDto testDto = testDto  = restTemplate.postForObject(testEntity.getEndpoint(), authEntity, TestDto.class);

return testDto;
}
}
И эти запросы я отправляю в 4 потока:

Код: Выделить всё

List  futuresList = new ArrayList();
ExecutorService pool = Executors.newFixedThreadPool(4);
for (Integer i=0; i

Подробнее здесь: [url]https://stackoverflow.com/questions/66224688/spring-boot-callable-401-unauthorized-no-body[/url]

Вернуться в «JAVA»