title: Feign Request Interceptor dynamic values
body: <p>I'm client of some APIs that I need to send a token in every request, and in order to get this token I need to access <code>/auth/token</code> sending username and password, and thought about using a request interceptor to solve it. But username and password are different per request, there is some way to use dynamic values in feign request interceptor or before every API call I'll need to call <code>/auth/token</code> using a normal feign client?</p>
  
  <p>I have a <code>Service</code> that access this token API</p>
  
  <pre><code>@Service
  @RequiredArgsConstructor
  public class AuthService {
    private final AuthClient client;
    private final AuthProperties properties;
  
    @Cacheable("tokens")
    public AuthToken getToken(AuthUser user) {
        return client.authenticate(properties.getClientId(), properties.getSecret(), user.getUser(),
              user.getPassword());
    }
  }
  </code></pre>
  
  <p>A feign client to access the token API</p>
  
  <pre><code>public interface AuthClient {
    @RequestLine("GET /token?client_id={client_id}&amp;client_secret={client_secret}&amp;grant_type=password&amp;username={username}&amp;password={password}")
    AuthToken authenticate(@Param("client_id") String client_id, @Param("client_secret") String client_secret,
                              @Param("username") String username, @Param("password") String password);
  }
  </code></pre>
  
  <p>And a <code>RequestInterceptor</code> that uses this service</p>
  
  <pre><code>@RequiredArgsConstructor
  public class AuthRequestInterceptor implements RequestInterceptor {
  
    private final AuthUser user;
    @Autowired
    private final AuthService authService;
  
    @Override
    public void apply(RequestTemplate template) {
      AuthToken token = authService.getToken(user);
      template.header("Authorization", "Bearer " + token.getAccess_token());
    }
  }
  </code></pre>
  
  <p>I'm not sure how to add this interceptor when building the feign client to set the user per request </p>