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);
}
Answer from Hasnain on Stack Overflow
🌐
Baeldung
baeldung.com › home › rest › setting request headers using feign
Setting Request Headers Using Feign | Baeldung
March 25, 2026 - Let’s think of a scenario where specific API calls should always contain a static header. In this situation, we might configure that request header as part of the client. A typical example is to include a Content-Type header.
🌐
Medium
medium.com › @mtl98 › sending-headers-in-feign-client-94096c9069e6
Sending Headers in Feign Client | by Mohammed Taoufik Lahmidi | Medium
December 13, 2024 - The @RequestHeader annotation is straightforward and convenient for adding headers to specific methods in your Feign client. Here's how you can use it: First, create an interface and annotate it with @FeignClient. This tells Spring to create a bean for this interface and handle the communication. import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestHeader; @FeignClient(name = "example-client", url = "http://example.com") public interface ExampleClient { @GetMapping("/api/v1/resource") String getResourceV1(@RequestHeader("Custom-Header") String headerValue); @GetMapping("/api/v2/resource") String getResourceV2(@RequestHeader Map<String,String> headerValues); }
🌐
GitHub
github.com › OpenFeign › feign
GitHub - OpenFeign/feign: Feign makes writing java http clients easier · GitHub
These approaches specify header entries as part of the api and do not require any customizations when building the Feign client. To customize headers for each request method on a Target, a RequestInterceptor can be used. RequestInterceptors can be shared across Target instances and are expected to be thread-safe. RequestInterceptors are applied to all request methods on a Target. If you need per method customization, a custom Target is required, as the a RequestInterceptor does not have access to the current method metadata. For an example of setting headers using a RequestInterceptor, see the Request Interceptors section.
Author: OpenFeign
🌐
Arnoldgalovics
arnoldgalovics.com › spring-cloud-feign-headers
Passing headers with Spring Cloud Feign – Arnold Galovics
On the app side, I have the Feign client in the following way: @FeignClient(name = "translation", url = "http://localhost:9001") public interface TranslationClient { @RequestMapping("/message") MessageResponse message(@RequestHeader("Accept-Language") String language); } As you can see, I used the very same Spring MVC annotation for passing the language header. And here’s an example controller which triggers the functionality:
🌐
GitConnected
levelup.gitconnected.com › feign-client-query-parameters-and-headers-08677ed260b1
Feign client Query Parameters and Headers | by Ivan Polovyi | Level Up Coding
April 4, 2025 - Feign client Query Parameters and Headers This tutorial will provide explanations with examples of how to use query parameters and headers in a Feign client. This friendly link is for those without a …
🌐
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
🌐
Spring
docs.spring.io › spring-cloud-openfeign › docs › current › reference › html
Spring Cloud OpenFeign
The Logger.Level object that you may configure per client, tells Feign how much to log. Choices are: NONE, No logging (DEFAULT). BASIC, Log only the request method and URL and the response status code and execution time. HEADERS, Log the basic information along with request and response headers. FULL, Log the headers, body, and metadata for both requests and responses. For example, the following would set the Logger.Level to FULL:
🌐
Medium
medium.com › @IlyasKeser › feignclient-interceptor-for-bearer-token-oauth-f45997673a1
FeignClient Interceptor for Bearer Token/OAuth | by Ilyas Keser | Medium
October 20, 2019 - @Component public class FeignClientInterceptor implements RequestInterceptor { private static final String AUTHORIZATION_HEADER="Authorization"; private static final String TOKEN_TYPE = "Bearer"; @Override public void apply(RequestTemplate requestTemplate) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null && authentication.getDetails() instanceof OAuth2AuthenticationDetails) { OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) authentication.getDetails(); requestTemplate.header(AUTHORIZATION_HEADER, String.format("%s %s", TOKEN_TYPE, details.getTokenValue())); } } } …using the interceptor the Feign client doesn’t need to specify the token in each method signature:
Find elsewhere
🌐
Fullstackdeveloper
fullstackdeveloper.guru › 2020 › 05 › 15 › how-to-send-multiple-headers-using-open-feign
How to send multiple headers using Open Feign ? – The Full Stack Developer
March 24, 2021 - package com.springboot.openfeign; import java.util.List; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @FeignClient(name = "personclient", url = "http://localhost:8090/") public interface PersonClient { @RequestMapping(method = RequestMethod.GET, value = "/persons") List&lt;Person&gt; getPersons(@RequestHeader("Authorization") String header, @RequestHeader("color-of-my-bike") String bikeColor); }
🌐
Javadoc.io
javadoc.io › static › com.netflix.feign › feign-core › 6.0.1 › feign › Headers.html
Headers (feign-core 6.0.1 API)
@RequestLine("GET /") @Headers("Cache-Control: max-age=640000") ... @RequestLine("POST /") @Headers({ "X-Foo: Bar", "X-Ping: {token}" }) void post(@Named("token") String token); ... Note: Headers do not overwrite each other. All headers with the same name will be included in the request.
🌐
Codeboje
codeboje.de › getting-started-feignclient
Getting Started with Feign Client in Spring - codeboje
January 15, 2020 - We can always pass down authentication headers using the @RequestHeader annotation on each method. However, there is also an alternative way to specify that globally. Like Spring MVC, Feign has an interceptor concept, which can be used to do specific stuff before a remote call.
🌐
Medium
medium.com › @jrcdsf › injecting-url-and-headers-dynamically-at-feign-client-9f63eb612367
Injecting URL and Headers dynamically at Feign Client | by José Roberto Costa | Medium
June 22, 2022 - package com.jrcdsf.integration.client.infrastructure.inbound.http; import com.jrcdsf.integration.client.core.exceptions.*; import com.jrcdsf.integration.client.infrastructure.domain.Customers; import feign.HeaderMap; import feign.RequestLine; import java.util.Map; public interface FeignCustomClient { @RequestLine("GET") @HandleFeignError(GetCustomersExceptionHandler.class) Customers getCustomers(@HeaderMap Map<String, Object> headerMap); }
🌐
Javahowtos
javahowtos.com › demo slot › slot demo gacor › slot gacor
Simulasi Real-Time Demo Gacor: Rasakan Sensasi Maxwin X1000 dengan Akun Demo PG Soft & Pragmatic Play Terbaru 2026
DEMO SLOT - Coba Demo Slot Gratis terbaru 2026 tanpa deposit. Pelajari setiap fitur Pragmatic Play dan PG Soft. Manfaatkan simulasi real-time anti lag untuk menguji strategi dan temukan kunci rahasia Maxwin X1000.
(5.0)
Price: IDR 97,962
Top answer
1 of 3
8

You simple pass your header as an argument and you declare your method in your interface accordingly. Please find snippet of code below.

And when you run your Feign client with logging level full (feign.client.config.default.loggerLevel=full), you'll see the authorization header (being an OAuth Bearer access token in my case).

Hopefully this helps.

All the best, Wim

@FeignClient(name="mde", url="${MDE.campaignServiceEndpoint}")
public interface CampaignClientService {
    @RequestMapping(method = RequestMethod.GET, value = "/useCases/search/findByName?name={name}")
    @Cacheable("placementUseCase")
    PlacementUseCase findUseCaseByName(@RequestHeader(value = "Authorization", required = true) String authorizationHeader, @PathVariable("name") String name);
2 of 3
1

If you are using Feign client directly without spring

then you can pass Header params something like this, in Feign Interface

@Headers("Content-Type: application/json")
@RequestLine("PATCH infusionsoft/contacts/{contactId}?format={format}")
InfusionsoftFullContact updateContact(@Param("contactId") Long contactId,
                                      @Param("format") String format,
                                      InfusionsoftFullContact contact,
                                      @HeaderMap Map<String, Object> headerMap);

Where HeaderParams can be as below

Map<String, Object> headerMap = new HashMap<>();
    
headerMap.put("application", "FDX");
headerMap.put("Authorization", "Basic aW5mdXNpb25zb2Z0OnBhc3N3b3Jk");
headerMap.put("platform",user.getPlatform());
headerMap.put("platformKey", user.getPlatformKey());
headerMap.put("email",user.getEmail());
headerMap.put("Content-Type", MediaType.APPLICATION_JSON);
Top answer
1 of 2
11

You can create an interceptor that'd inject headers in all requests as below:

@Bean
public RequestInterceptor requestInterceptor() {
  return requestTemplate -> {
      requestTemplate.header("user", username);
      requestTemplate.header("password", password);
      requestTemplate.header("Accept", ContentType.APPLICATION_JSON.getMimeType());
  };
}

Also it provides a way to set interceptor using property files as below:

feign:
  client:
    config:
      default:
        requestInterceptors:
          com.baeldung.cloud.openfeign.JSONPlaceHolderInterceptor

we can create the configuration with default as the client name to configure all @FeignClient objects, or we can declare the feign client name for a configuration

Reference: https://www.baeldung.com/spring-cloud-openfeign

EDIT: Another way is to set headers in yml as below:

feign:
  client:
    config:
      default:
        defaultRequestHeaders:
          Authorization:
            - Basic dXNlcjpwYXNzd29yZA==
          SomeOtherHeader:
            - Value1
            - Value2
2 of 2
2

we have used below for kotlin to make sure we add proper headers to all the request sent :

Feign client with configuration setup

@FeignClient(name = "YourClient", url = "\${base-url}", configuration = [FeignHeaderConfiguration::class])
interface YourClient 

Header configuration

@Configuration
class FeignHeaderConfiguration {

    @Bean
    fun clientHeaderInterceptor(): ClientHeaderInterceptor {
        return ClientHeaderInterceptor()
    }
}

and interceptor where we added the header

class ClientHeaderInterceptor : RequestInterceptor {
    override fun apply(requestTemplate: RequestTemplate) {
       requestTemplate.header("Accept", MediaType.APPLICATION_JSON_VALUE)
    }
}
🌐
GitHub
github.com › OpenFeign › feign › blob › master › README.md
feign/README.md at master · OpenFeign/feign
These approaches specify header entries as part of the api and do not require any customizations when building the Feign client. To customize headers for each request method on a Target, a RequestInterceptor can be used. RequestInterceptors can be shared across Target instances and are expected to be thread-safe. RequestInterceptors are applied to all request methods on a Target. If you need per method customization, a custom Target is required, as the a RequestInterceptor does not have access to the current method metadata. For an example of setting headers using a RequestInterceptor, see the Request Interceptors section.
Author: OpenFeign
🌐
GitHub
github.com › OpenFeign › feign › blob › master › core › src › main › java › feign › Headers.java
feign/core/src/main/java/feign/Headers.java at master · OpenFeign/feign
* </ul> * * <br> * <b>Relationship ... <br> * <br> * Feign: * * <pre> * &#64;RequestLine("POST /") * &#64;Headers({ * "X-Ping: {token}" * }) void post(&#64;Named("token") String token); * ......
Author: OpenFeign