# Unable to add audience parameter to getAccessTokenSilently

**URL:** <https://community.auth0.com/t/unable-to-add-audience-parameter-to-getaccesstokensilently/136606>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [June 18, 2024, 8:15pm UTC](https://community.auth0.com/t/unable-to-add-audience-parameter-to-getaccesstokensilently/136606 "2024-06-18T20:15:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gt2960](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gt2960/32/55993_2.png) [@gt2960](https://community.auth0.com/u/gt2960)\
**Post date:** [June 18, 2024, 8:15pm UTC](https://community.auth0.com/t/unable-to-add-audience-parameter-to-getaccesstokensilently/136606/1 "2024-06-18T20:15:51Z")

</div>

I am trying to generate a JWT token with the getAccessTokenSilently, but when I try to add the audience parameter to the function I get this error: “No overload matches this call.”.

Here is the react typescript code snippet:

function App() {  
const {user, isAuthenticated, isLoading , getAccessTokenSilently} = useAuth0();  
const [token, setToken] = useState();  
useEffect(() =\> {  
(async () =\> {  
try {  
const accessToken: any = await getAccessTokenSilently({  
audience: ‘API\_IDENTIFIER’  
});  
setToken(accessToken);  
} catch (error) {  
console.error(‘Error fetching access token’, error);

```
  }
})();

```

}, [getAccessTokenSilently]);

What can I do to fix this?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [June 18, 2024, 8:52pm UTC](https://community.auth0.com/t/unable-to-add-audience-parameter-to-getaccesstokensilently/136606/3 "2024-06-18T20:52:27Z")

</div>

Hey there @gt2960 !

I’m not positive what that error means, but passing the audience param in `authorizationParams` may resolve it:

```auto
 const accessToken = await getAccessTokenSilently({
          authorizationParams: {
            audience: "API_IDENTIFIER"
          }

```

---

<div class="post-metadata">

**Author:** ![gt2960](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gt2960/32/55993_2.png) [@gt2960](https://community.auth0.com/u/gt2960)\
**Post date:** [June 18, 2024, 11:40pm UTC](https://community.auth0.com/t/unable-to-add-audience-parameter-to-getaccesstokensilently/136606/4 "2024-06-18T23:40:46Z")

</div>

Thanks that worked! What should go inside of the “API\_IDENTIFIER” field?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [June 19, 2024, 2:26pm UTC](https://community.auth0.com/t/unable-to-add-audience-parameter-to-getaccesstokensilently/136606/5 "2024-06-19T14:26:29Z")

</div>

Awesome, thanks for confirming!

> [@gt2960](#):
>
> What should go inside of the “API\_IDENTIFIER” field?

The `API_IDENTIFIER` field is the identifier which you give an API when registering it in Auth0:

> **[Register APIs](https://auth0.com/docs/get-started/auth0-overview/set-up-apis)**
>
> Learn how to register APIs in the Auth0 Dashboard.

---

<div class="post-metadata">

**Author:** ![gt2960](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gt2960/32/55993_2.png) [@gt2960](https://community.auth0.com/u/gt2960)\
**Post date:** [June 19, 2024, 3:56pm UTC](https://community.auth0.com/t/unable-to-add-audience-parameter-to-getaccesstokensilently/136606/6 "2024-06-19T15:56:37Z")

</div>

> [@ty.frith](#):
>
> The `API_IDENTIFIER` field is the identifier which you give an API when registering it in Auth

Does it matter which API I use?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [June 19, 2024, 4:53pm UTC](https://community.auth0.com/t/unable-to-add-audience-parameter-to-getaccesstokensilently/136606/7 "2024-06-19T16:53:59Z")

</div>

Yes, the [audience](https://community.auth0.com/t/what-is-the-audience/71414) should be that of the resource server or API the access token is meant to be used to access.

---

<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:** [July 3, 2024, 4:54pm UTC](https://community.auth0.com/t/unable-to-add-audience-parameter-to-getaccesstokensilently/136606/8 "2024-07-03T16:54:12Z")

</div>

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