Below is a sample code to implement ResponseInterceptor for openfeign with spring-boot.

import feign.InvocationContext;
import feign.ResponseInterceptor;
import org.springframework.stereotype.Component;

@Component
public class FeignClientInterceptor implements ResponseInterceptor {

    @Override
    public Object aroundDecode(InvocationContext invocationContext) {

        feign.Response response= invocationContext.response();
        feign.Request request=response.request();

        //Do something with request and response        

        return invocationContext.proceed();
    }
}

Dependency used for this example:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>2022.0.1</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>
</dependencies>
Answer from zenuve on Stack Overflow
🌐
Baeldung
baeldung.com › home › rest › setting request headers using feign
Setting Request Headers Using Feign | Baeldung
March 25, 2026 - Multiple Request interceptors can also be applied to the Feign client.
🌐
Medium
medium.com › @sachinsindhu › feign-client-request-interceptor-pit-falls-f7f08ff61b74
Feign client Request Interceptor Pit falls | by Sachin Sindhu | Medium
September 11, 2023 - Instead of creating different interceptor for every service , we can create a single interceptor and have our custom factory to provide interceting logic for different services. CustomRequestInterceptor: RequestTemplate contains feignTarget object which is basically the feign client that made that request with some other data as well.
Discussions

java - Feign response interceptor using Spring Cloud OpenFeign - Stack Overflow
Feign now supports ResponseInterceptor class. Can I somehow implement it using Spring Cloud Feign or I need to use Feign.builder()? Tried like this in my custom FeignConfig: @Bean public More on stackoverflow.com
🌐 stackoverflow.com
Support Response Interceptors
In my project, I use the request interceptor to sign the request. I thought that there would be a corresponding response interceptor to verify the signature, but I didn't find it. Is there a be... More on github.com
🌐 github.com
12
November 30, 2019
Response interceptor is not intercepting response
The README just tells us that it is possible, and gives us an example of a prebuilt response interceptor (side note, the RedirectionInterceptor that the README says Feign includes is not actually included with the package -- auto-import does not resolve it, and I'm unable to find it anywhere ... More on github.com
🌐 github.com
5
August 8, 2024
Response interceptor not getting picked from Capability
We recently upgraded our Feign client from version 12.5 to 13.5 and have encountered an issue post-upgrade. Specifically, the method public ResponseInterceptor enrich(ResponseInterceptor responseInterceptor) within our custom capability is no longer being executed and hence the response interceptor ... More on github.com
🌐 github.com
0
July 4, 2025
🌐
OneUptime
oneuptime.com › home › blog › how to implement custom feign interceptors
How to Implement Custom Feign Interceptors
January 30, 2026 - sequenceDiagram participant Client as Feign Client participant I1 as Interceptor 1 participant I2 as Interceptor 2 participant Target as Target Service Client->>I1: RequestTemplate I1->>I1: Add Auth Header I1->>I2: Modified RequestTemplate I2->>I2: Add Correlation ID I2->>Target: HTTP Request Target-->>Client: Response
Top answer
1 of 3
2

Below is a sample code to implement ResponseInterceptor for openfeign with spring-boot.

import feign.InvocationContext;
import feign.ResponseInterceptor;
import org.springframework.stereotype.Component;

@Component
public class FeignClientInterceptor implements ResponseInterceptor {

    @Override
    public Object aroundDecode(InvocationContext invocationContext) {

        feign.Response response= invocationContext.response();
        feign.Request request=response.request();

        //Do something with request and response        

        return invocationContext.proceed();
    }
}

Dependency used for this example:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>2022.0.1</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>
</dependencies>
2 of 3
1

I dit not succeeded in using the ResponseInterceptor.

But I've found an alternative using the feign.codec.Decoder.

In this example, I'm reading the Content-Language of every Feign client responses :

public class ClientResponseInterceptor implements Decoder {

    private final JacksonDecoder delegate;

    public ClientResponseInterceptor(JacksonDecoder delegate) {
        this.delegate = delegate;
    }

    @Override
    public Object decode(Response response, Type type) throws IOException, FeignException {
        String contentLanguageFromFeignResponse;

        Collection<String> contentLanguage = response.headers().get(HttpHeaders.CONTENT_LANGUAGE);
        // Extract this part in another method
        if (contentLanguage != null && !contentLanguage.isEmpty()) {
            Optional<String> attributeOpt = contentLanguage.stream().findFirst();
            if (attributeOpt.isPresent()) {
                contentLanguageFromFeignResponse = attributeOpt.get();
            }
        }

        // Do something with contentLanguageFromFeignResponse

        return delegate.decode(response, type);
    }
}

And declaring it in your feign config file :

@Bean
public ClientResponseInterceptor responseInterceptor() {
    return new ClientResponseInterceptor(new JacksonDecoder(/*objectMapper*/));
}

(You can use another Decoder, JacksonDecoder is just an example)

🌐
GitHub
github.com › OpenFeign › feign › issues › 1126
Support Response Interceptors · Issue #1126 · OpenFeign/feign
November 30, 2019 - In my project, I use the request interceptor to sign the request. I thought that there would be a corresponding response interceptor to verify the signature, but I didn't find it. Is there a be...
Author: OpenFeign
🌐
DEV Community
dev.to › tarcalia › feign-clients-with-multiple-interceptors-in-spring-boot-hh2
Feign Clients with Multiple Interceptors in Spring Boot - DEV Community
June 18, 2025 - When working with Spring Boot and OpenFeign, it's quite common to add custom headers to outbound HTTP requests — like tracking IDs, authentication tokens, or metadata provided by libraries. But what happens when you want to add multiple interceptors in a clean, reusable, and testable way? This blog post shows you how to chain multiple Feign RequestInterceptor instances using a composite pattern.
🌐
Spring Cloud
cloud.spring.io › spring-cloud-openfeign › multi › multi_spring-cloud-feign.html
1. Declarative REST Client: Feign
In some cases it might be necessary to customize your Feign Clients in a way that is not possible using the methods above. In this case you can create Clients using the Feign Builder API. Below is an example which creates two Feign Clients with the same interface but configures each one with a separate request interceptor.
Find elsewhere
🌐
Javadoc.io
javadoc.io › doc › io.github.openfeign › feign-core › 10.12 › feign › RequestInterceptor.html
RequestInterceptor - feign-core 10.12 javadoc
Bookmarks · Latest version of io.github.openfeign:feign-core · https://javadoc.io/doc/io.github.openfeign/feign-core · Current version 10.12 · https://javadoc.io/doc/io.github.openfeign/feign-core/10.12 · package-list path (used for javadoc generation -link option) · https://javadoc....
🌐
Medium
medium.com › @aravindcsebe › mastering-feign-requestinterceptor-from-authentication-to-advanced-use-cases-d78fad055af5
Mastering Feign RequestInterceptor: From Authentication to Advanced Use Cases | by Spring Boot Simplified | Medium
February 9, 2026 - Not Handling Null Values: Always check for null before accessing authentication contexts. Feign’s RequestInterceptor is a powerful tool that goes far beyond simple authentication.
🌐
Medium
medium.com › @saiteja-erwa › feign-client-requestinterceptors-2435f4e5cfb1
Feign Client: RequestInterceptors - Saiteja Erwa - Medium
May 18, 2024 - @FeignClient(value="service-b", url="placeholder-url", configuration=FeignConfig.class) public interface commonFiegnClient { //requests to service-b } Interceptor will be called for every request, and add data using the provided RequestTemplate.
🌐
GitHub
github.com › OpenFeign › feign › issues › 2503
Response interceptor is not intercepting response · Issue #2503 · OpenFeign/feign
August 8, 2024 - The README just tells us that it is possible, and gives us an example of a prebuilt response interceptor (side note, the RedirectionInterceptor that the README says Feign includes is not actually included with the package -- auto-import does not resolve it, and I'm unable to find it anywhere in version 11.10)
Author: OpenFeign
🌐
GitHub
github.com › OpenFeign › feign › issues › 2935
Response interceptor not getting picked from Capability · Issue #2935 · OpenFeign/feign
July 4, 2025 - We recently upgraded our Feign client from version 12.5 to 13.5 and have encountered an issue post-upgrade. Specifically, the method public ResponseInterceptor enrich(ResponseInterceptor responseInterceptor) within our custom capability is no longer being executed and hence the response interceptor is not getting used at all.
Author: OpenFeign
Top answer
1 of 3
25

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.

That being 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:

@Bean
public RequestInterceptor basicAuthRequestInterceptor() {
    return new BasicAuthRequestInterceptor("username", "password");
}
2 of 3
12

I know the thread is a bit old but wanted to give some explanation on what's happening here.

If you'd like to customize your Feign requests, you can use a RequestInterceptor. This can be a custom implementation or you can reuse what's available in the Feign library, e.g. BasicAuthRequestInterceptor.

How to register it? Well, there are 2 ways to do it depending on how you use Feign.

If you're using plain Feign without Spring, then you gotta set the interceptor to the Feign builder. An example is here.

Feign.builder()
     .requestInterceptor(new MyCustomInterceptor())
     .target(MyClient.class, "http://localhost:8081");

If you're using Spring Cloud OpenFeign and you use the @FeignClient annotation to construct your clients, then you have to create a bean from your RequestInterceptor by either defining it as a @Component or as a @Bean in one of your @Configuration classes. Example here.

@Component
public class MyCustomInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        // do something
    }
}

Also, you can check out one of my articles in this topic, maybe that clears it up better: Customizing each request with Spring Cloud Feign

🌐
Medium
medium.com › @babalolaopedaniel › how-to-use-feign-client-with-interceptors-for-authentication-in-a-spring-boot-application-71d46ba89c06
How to Use Feign Client with Interceptors for Authentication in a Spring Boot Application | by Babalola Opeyemi | Medium
December 29, 2024 - Feign was developed by Netflix and now part of the Spring Cloud ecosystem. It makes writing HTTP clients easier by allowing you to define them through simple interfaces using annotations. This article will guide you through creating a Spring Boot project that uses Feign clients with interceptors for handling authentication.
🌐
Baeldung
baeldung.com › home › spring › spring cloud › introduction to spring cloud openfeign
Introduction to Spring Cloud OpenFeign | Baeldung
February 19, 2026 - Adding interceptors is another useful feature provided by Feign. The interceptors can perform a variety of implicit tasks, from authentication to logging, for every HTTP request/response.
🌐
Medium
medium.com › @piszu › feign-client-is-not-so-simple-as-we-want-case-study-920e4901e27b
Feign Client is not so simple as we want — case study | by Mariusz Pisz | Medium
October 27, 2019 - Ok, now it works, we catch exception caused by 302 response using ErrorDecoder and we return correct response from it. If we stand aside and look at it, it looks like some kind of hack… Can we do something more with that to make it better? I spent some time on talks and one of my colleagues after reviewing this article gave me advice to not use default Feign HTTP client and replace them by okHttpClient. So let’s check how it will work. First lets build an interceptor for okHttpClient which will catch our response and change status for it to 200.
🌐
DEV Community
dev.to › sabyasachi › spring-feign-client-3853
Spring Feign Client - DEV Community
August 28, 2022 - We see userid is added to the response. A very useful application for interceptor is when feign has to send oauth2 access token . Out of the spring provides a OAuth2FeignRequestInterceptor which adds access token for each request. From spring boot 2.4.0 feign has integration with spring-cloud-loadbalancer which can fetch client url info from various service discovery providers and make that info available to feign .
🌐
GitHub
github.com › OpenFeign › feign › blob › master › core › src › main › java › feign › RequestInterceptor.java
feign/core/src/main/java/feign/RequestInterceptor.java at master · OpenFeign/feign
package feign; · /** * Zero or more {@code RequestInterceptors} may be configured for purposes such as adding headers to · * all requests. No guarantees are given with regards to the order that interceptors are applied. * Once interceptors are applied, {@link Target#apply(RequestTemplate)} is called to create the · * immutable http request sent via {@link Client#execute(Request, feign.Request.Options)}. <br> * <br> * For example: <br> * * <pre> * public void apply(RequestTemplate input) { * input.header(&quot;X-Auth&quot;, currentToken); * } * </pre> * * <br> * <br> * <b>Configuration</b><br> * <br> * {@code RequestInterceptors} are configured via {@link Feign.Builder#requestInterceptors}. <br> * <br> * <b>Implementation notes</b><br> * <br> * Do not add parameters, such as {@code /path/{foo}/bar } in your implementation of {@link ·
Author: OpenFeign
🌐
CodingTechRoom
codingtechroom.com › question › how-to-implement-a-feign-response-interceptor-in-spring-cloud-openfeign
How to Implement a Feign Response Interceptor in Spring Cloud OpenFeign - CodingTechRoom
Implement a custom response interceptor by extending `ErrorDecoder`. Register the interceptor as a Spring bean to enable automatic discovery and usage by Feign clients.