Spring

Spring Batch and Feign OAuth2 RequestInterceptor

Posted on by  
Willem Cheizoo

We have a microservice architecture with one of the microservices having a Spring Batch job which processes a CSV file and calling another microservice. Both microservices are OAuth2 protected ResourceServers. When we call the first microservice, a batch job is started and we want the Authorization header to be passed to the second microservice. The solution can be defined as: In a Feign RequestInterceptor, grab the current OAuth access_token and pass it on the the RequestTemplate with Hystrix running in SEMAPHORE execution isolation strategy

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableResourceServer
@EnableOAuth2Client
public class MyApplication {

  public static void main(String[] args) {
    SpringApplication.run(MyApplication .class, args);
  }
}

Continue reading →

shadow-left