# Added Audience and STILL getting Opaque token instead of JWT token with React

**URL:** <https://community.auth0.com/t/added-audience-and-still-getting-opaque-token-instead-of-jwt-token-with-react/110636>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-react\
**Created:** [July 5, 2023, 8:04pm UTC](https://community.auth0.com/t/added-audience-and-still-getting-opaque-token-instead-of-jwt-token-with-react/110636 "2023-07-05T20:04:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicktb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicktb/32/48585_2.png) [@nicktb](https://community.auth0.com/u/nicktb)\
**Post date:** [July 5, 2023, 8:04pm UTC](https://community.auth0.com/t/added-audience-and-still-getting-opaque-token-instead-of-jwt-token-with-react/110636/1 "2023-07-05T20:04:24Z")

</div>

Hello,

I’m currently developing a React application using Auth0 for authentication. I have set up the Auth0Provider with the correct audience and I’m using the getAccessTokenSilently method to retrieve the access token.

However, I’m encountering an issue where I’m receiving an opaque token instead of the expected JWT token. This is causing problems when I try to use this token to authenticate with my API.

Good to note, my client side code is deployed with AWS Amplify

Here’s the relevant code in my application:

```auto
<Auth0Provider
domain={process.env.REACT_APP_AUTH0_DOMAIN}
clientId={process.env.REACT_APP_CLIENT_ID}
redirectUri={window.location.origin}
onRedirectCallback={onRedirectCallback}
audience=‘API IDENTIFIER URL’

```

And in my Profile.js:

```auto
const token = await getAccessTokenSilently({
audience: ‘API IDENTIFIER URL’
});

```

I’ve checked my Auth0 application and API settings, and everything seems to be configured correctly. I’m not sure why I’m receiving an opaque token instead of a JWT token.

Any help or suggestions would be greatly appreciated. Thank you!

 ![Screenshot 2023-07-05 at 7.05.55 PM](https://global.discourse-cdn.com/auth0/original/3X/c/7/c70065441ca0ddd296792eadbc465f3588b58604.png)

---

<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:** [July 5, 2023, 11:25pm UTC](https://community.auth0.com/t/added-audience-and-still-getting-opaque-token-instead-of-jwt-token-with-react/110636/3 "2023-07-05T23:25:39Z")

</div>

Hey there @nicktb!

Do you mind [sharing a har file](https://auth0.com/docs/troubleshoot/troubleshooting-tools/generate-and-analyze-har-files) for a user logging in through you React app?

You may also want to look into adding [authorizationParams](https://auth0.github.io/auth0-react/interfaces/AuthorizationParams.html) to your `Auth0Provider` - The `audience` might not be included in the authorize call constructed by the React SDK. It might look like:

```auto
<Auth0Provider
    domain="your_domain.us.auth0.com"
    clientId="client_id"
    authorizationParams={{
      redirect_uri: window.location.origin,
      audience: "https://test-api-endpoint",
      scope: "openid profile"
    }}
  >
    <App />
  </Auth0Provider>

```

Keep us posted!

---

<div class="post-metadata">

**Author:** ![nicktb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicktb/32/48585_2.png) [@nicktb](https://community.auth0.com/u/nicktb)\
**Post date:** [July 5, 2023, 11:28pm UTC](https://community.auth0.com/t/added-audience-and-still-getting-opaque-token-instead-of-jwt-token-with-react/110636/4 "2023-07-05T23:28:42Z")

</div>

Done! Where would you like me to share the HAR?

Can I send it through a PM?

---

<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:** [July 5, 2023, 11:29pm UTC](https://community.auth0.com/t/added-audience-and-still-getting-opaque-token-instead-of-jwt-token-with-react/110636/5 "2023-07-05T23:29:20Z")

</div>

> [@nicktb](#):
>
> Can I send it through a PM?

Yep! I should’ve mentioned that 🙂

---

<div class="post-metadata">

**Author:** ![nicktb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicktb/32/48585_2.png) [@nicktb](https://community.auth0.com/u/nicktb)\
**Post date:** [July 5, 2023, 11:51pm UTC](https://community.auth0.com/t/added-audience-and-still-getting-opaque-token-instead-of-jwt-token-with-react/110636/6 "2023-07-05T23:51:46Z")

</div>

Actually no need, your suggestion fixed my problem! You are a life saver I’d been debugging this for nearly 8 hours.

For anyone who may be having a similar problem here is what fixed it.

**Solution:**

The issue was resolved by making two key changes:

1. **Setting the `audience` and `scope` in the `Auth0Provider`:** The `Auth0Provider` was set up with the `audience` and `scope` parameters. This ensures that these parameters are included in all authorization requests made by the Auth0 client. Here’s an example:

```auto
<Auth0Provider
  domain={process.env.REACT_APP_AUTH0_DOMAIN}
  clientId={process.env.REACT_APP_CLIENT_ID}
  redirectUri={window.location.origin}
  onRedirectCallback={onRedirectCallback}
  audience='API INDICATOR URL'
  scope='openid profile email'
>
  <App />
</Auth0Provider>

```

1. **Removing the `audience` parameter from the `getAccessTokenSilently` calls:** The `audience` parameter was removed from the `getAccessTokenSilently` calls. Since the `audience` is already specified in the `Auth0Provider`, it doesn’t need to be specified again in the `getAccessTokenSilently` calls.

Hope this helps someone down the line!

---

<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:** [July 5, 2023, 11:54pm UTC](https://community.auth0.com/t/added-audience-and-still-getting-opaque-token-instead-of-jwt-token-with-react/110636/7 "2023-07-05T23:54:14Z")

</div>

Wonderful! Happy to help and thanks for following up with the community 🤠

---

<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 19, 2023, 11:54pm UTC](https://community.auth0.com/t/added-audience-and-still-getting-opaque-token-instead-of-jwt-token-with-react/110636/8 "2023-07-19T23:54:43Z")

</div>

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