# React SDK with multiple audiences and refresh tokens

**URL:** <https://community.auth0.com/t/react-sdk-with-multiple-audiences-and-refresh-tokens/98748>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [January 23, 2023, 9:21pm UTC](https://community.auth0.com/t/react-sdk-with-multiple-audiences-and-refresh-tokens/98748 "2023-01-23T21:21:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonas.pauthier](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jonas.pauthier/32/42729_2.png) [@jonas.pauthier](https://community.auth0.com/u/jonas.pauthier)\
**Post date:** [January 23, 2023, 9:21pm UTC](https://community.auth0.com/t/react-sdk-with-multiple-audiences-and-refresh-tokens/98748/1 "2023-01-23T21:21:50Z")

</div>

I have setup a React application with `auth0/auth0-react@2.0.0` that communicates with two different APIs (API-1 and API-2). Both of these backends have an API created in Auth0 Dashboard with a different audience. `API-2` has RBAC and “Add permissions in Access Token” enabled. In the React application, the `Auth0Provider` is setup with `audience=API-1` since this is the main API. The frontend is served with HTTPS locally and a custom domain like `myapp.local.com` to prevent consent prompt in local development. In a specific page I make a request to `API-2`. I’m using:

```auto
getAccessTokenSilently({
  authorizationParams: {
    audience: "API-2",
    scope: "api-2-permission",
  },
});

```

To get an access token to request `API-2`.

This works if I use a browser that doesn’t have a strict third-party cookie policy i.e Chrome. If I use Brave with Shield enabled, I end up in a `login_required` error loop between my callback page and the universal login screen. I narrowed it down to Brave’s strict cookie policy. To escape from such problem, I tried to use refresh tokens. I enabled refresh tokens and offline access on both `API-1` and `API-2`. I set `useRefreshTokens={true}` on the Auth0Provider in the React app. I get the a refresh token when the app boots with the initial call to `/oauth/token`. However when I make the call to `API-2` I have an error saying: `Missing Refresh token ("audience" = "API-2")`.

Is it possible to have refresh tokens for a different audience than the one setup with the Auth0Provider without having to login again the user? If not, is the only way to prevent the `login_required` error to use a custom domain for our Auth0 account so the cookies would not get blocked?

Thank you.

---

<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:** [January 23, 2023, 10:13pm UTC](https://community.auth0.com/t/react-sdk-with-multiple-audiences-and-refresh-tokens/98748/2 "2023-01-23T22:13:29Z")

</div>

Hey there @jonas.pauthier!

> [@jonas.pauthier](#):
>
> Is it possible to have refresh tokens for a different audience than the one setup with the Auth0Provider without having to login again the user?

It is not possible to change the audience in this context - This is expected behavior. The refresh token flow will only provide an access token which matches that of the token previously received (possible to down scope).

It might be worth looking into configuring a single logical API to represent both APIs in order to simplify your use case:

> **[Configure Logical API for Multiple APIs](https://auth0.com/docs/get-started/apis/set-logical-api)**
>
> Learn how to use a single logical API in Auth0 to represent and control access to multiple APIs.

---

<div class="post-metadata">

**Author:** ![jonas.pauthier](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jonas.pauthier/32/42729_2.png) [@jonas.pauthier](https://community.auth0.com/u/jonas.pauthier)\
**Post date:** [January 24, 2023, 3:14pm UTC](https://community.auth0.com/t/react-sdk-with-multiple-audiences-and-refresh-tokens/98748/4 "2023-01-24T15:14:42Z")

</div>

Thank you @ty.frith for your answer. I will look into logical API and let you know.

---

<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:** [March 9, 2023, 1:22am UTC](https://community.auth0.com/t/react-sdk-with-multiple-audiences-and-refresh-tokens/98748/5 "2023-03-09T01:22:07Z")

</div>

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