Hello,
I am trying to configure an application M2M accessing a Resource Server configuring Spring 3.4.4 with Java 21.
I am trying to implement oAuth2Client lib (spring-security-oauth2-client) of Spring, but there is no documentation of how to set audience parameter to FeignClient can manage tokens automatically.
There are many customizations but no one works.
Someone have some example?
Hi @renan.padilha
I am not a Spring expert, however, if you are unable to customize the client by overriding the defaults as mentioned in this documentation, you can attempt to initialize the FeignClient and pass in request headers and parameters in which you can inclue the necessary information to handle the M2M communication:
@FeignClient(name="myClient", url = "{{application_url}}", configuration = {{confguration_file}}.class)
public interface MyClient {
@RequestMapping(method = RequestMethod.GET, value = "{{auth0_endpoint}}")
@Headers("Accept", "Content-Type: application/json")
public String audience(@Param("{{your_audience}}") String audience;
You can look to some alternative approaches in this Github Issue or this blog about setting request headers using Feign.
Let me know if the proposed solutions above work!
Kind Regards,
Nik