# How to set audience in application M2M

**URL:** <https://community.auth0.com/t/how-to-set-audience-in-application-m2m/185162>\
**Category:** Get Help\
**Tags:** oauth-2-0, protocols\
**Created:** [April 8, 2025, 1:40pm UTC](https://community.auth0.com/t/how-to-set-audience-in-application-m2m/185162 "2025-04-08T13:40:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![renan.padilha](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/renan.padilha/32/71378_2.png) [@renan.padilha](https://community.auth0.com/u/renan.padilha)\
**Post date:** [April 8, 2025, 1:40pm UTC](https://community.auth0.com/t/how-to-set-audience-in-application-m2m/185162/1 "2025-04-08T13:40:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [April 8, 2025, 5:50pm UTC](https://community.auth0.com/t/how-to-set-audience-in-application-m2m/185162/3 "2025-04-08T17:50:19Z")

</div>

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](https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/#spring-cloud-feign-overriding-defaults), 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:

```auto
@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](https://github.com/OpenFeign/feign-form/issues/79) or this blog about [setting request headers using Feign](https://www.baeldung.com/java-feign-request-headers).

Let me know if the proposed solutions above work!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 22, 2025, 5:50pm UTC](https://community.auth0.com/t/how-to-set-audience-in-application-m2m/185162/4 "2025-04-22T17:50:44Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
