spring-cloud/spring-cloud-openfeign

Add header when requesting access token with OAuth2AccessTokenInterceptor

nazeem-soeltan-maersk opened this issue · 1 comments

One of the requirements of my oauth client is to pass a additional specific header with a value. I wasn't able to find a solution to this.

What I currently have:

application.yml

spring:
  security:
    oauth2:
      client:
        registration:
          arrow:
            clientId: ...
            clientSecret: ...
            authorization-grant-type: client_credentials
            client-authentication-method: client_secret_basic

ArowFeignConfiguration.java

@Bean
        OAuth2AccessTokenInterceptor oAuth2AccessTokenInterceptorOne(final OAuth2AuthorizedClientManager authorizedClientManager) {
            return new OAuth2AccessTokenInterceptor("arrow", authorizedClientManager);
        }

I've tried adding another RequestInterceptor, but it's ignored when doing to token-call.

I'm using Spring Boot 3.3.3

Hi @nazeem-soeltan-maersk, thanks for reporting the issue. I think adding an interceptor is the way to go at this point. We may reevaluate if we see more requests from the community for this kind of feature.