I have 3 services 1 authentication service(for example service A) and other 2 services(for example service B and service C) which are using same authentication A service.
I have method in service B like
@PostMapping("/update-account")
public ResponseEntity<Object> updateAccount(HttpServletRequest request,
OAuth2Authentication principal,
@RequestBody UpdateAccountDto updateAccountDto){
}
In this method I am calling other method where I have some logic and in the end I want to call endpoint of service C using restTemaplte
like this
String serviceBEndpoint= "localhost:8090/testapi/updateAccount";
URI serviceUri = UriComponentsBuilder.fromUriString(changeEmailUri)
.build()
.toUri();
HttpHeaders headers = new HttpHeaders();
headers.set("someheader", someheader);
HttpEntity<UpdateUserDto> request = new HttpEntity<>(updadteUserDto, headers);
restTemplate.postForEntity(serviceUri, request, AuthenticationSuccessDto.class);
User called endpoint of Service B with correct token(request is authenticated) and it is also legal to call service C from service B because request is authenticated, so how can I do it with correct way ?