I would like to use a @FeignClient in a simple spring boot application (CommandLineRunner) to call a microservice endpoint. How can I provide an OAuth2Authentication to call a protected endpoint like helloUser()
?
@FeignClient(name = "sampleService", contextId = "greetingService")
public interface GreetingService {
@GetMapping("/hello-anonymous")
String helloAnonymous();
@GetMapping("/hello-user")
@Secured({ Role.USER })
String helloUser();
@GetMapping("/hello-admin")
@Secured({ Role.ADMIN })
String helloAdmin();
}