Reputation: 250
I am using Feign Client to call another microservice as below:
@FeignClient("employee")
public interface EmployeeFeignClient {
@RequestMapping(
method= RequestMethod.GET,
value="/employee/code/{code}",
consumes="application/json"
)
EmployeeResponseEntity getEmployeeByCode(@PathVariable("code") String code);
}
The service which calls the employee service will have authentication bearer token in its request header. I need to pass this same token to the service call being made. Tried to find on how to achieve the same but could not. Some help would be nice.
Upvotes: 0
Views: 1292
Reputation: 69
It was answered before.
The solution is to use @RequestHeader annotation instead of feign specific annotations
@FeignClient(name="Simple-Gateway")
interface GatewayClient {
@RequestMapping(method = RequestMethod.GET, value = "/gateway/test")
String getSessionId(@RequestHeader("X-Auth-Token") String token);
}
Upvotes: 1