How to add a request interceptor to a feign client? How to add a request interceptor to a feign client? spring spring

How to add a request interceptor to a feign client?


You don't really need your own implementation of the FeignRequestInterceptor as there is already BasicAuthRequestInterceptor in the feign.auth package that does exactly the same.

With this said, you basically have almost everything set up already. All is left to do is to define the basicAuthRequestInterceptor bean with specific username and password:

@Beanpublic RequestInterceptor basicAuthRequestInterceptor() {    return new BasicAuthRequestInterceptor("username", "password");}