# Auth0.js - not returning the correct audience

**URL:** <https://community.auth0.com/t/auth0-js-not-returning-the-correct-audience/6480>\
**Category:** Get Help\
**Tags:** jwt, audience, javascript\
**Created:** [May 4, 2017, 3:52pm UTC](https://community.auth0.com/t/auth0-js-not-returning-the-correct-audience/6480 "2017-05-04T15:52:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![roje](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/roje/32/3279_2.png) [@roje](https://community.auth0.com/u/roje)\
**Post date:** [May 4, 2017, 3:52pm UTC](https://community.auth0.com/t/auth0-js-not-returning-the-correct-audience/6480/1 "2017-05-04T15:52:29Z")

</div>

Hi guys.

I am trying to create a front-end application that uses the auth0 javascript SDK. This works fine and returns a JWT token as expected. But when I want to call an API with the same token it didnt work since the token is not for that audience. I tried adding audience to the code but for some reason the token keep having the `clientID` as the `aud`.

```
var webAuth = new auth0.WebAuth({
    domain: 'domain.eu.auth0.com',
    clientID: 'VaNkT5yOxGXMtdN7UVlKdFGy7daCGOJ0',
    responseType: 'token',
    audience: 'https://myapi.com'
});

$('.signin-db').on('click', function() {
    webAuth.redirect.loginWithCredentials({
        connection: 'Username-Password-Authentication',
        username: $("#email").val(),
        password: $("#password").val(),
        scope: 'openid',
    }, function (err, authResult) {
        console.log(err);
    });
});

```

JWT

```
{
  "iss": "https://domain.eu.auth0.com/",
  "sub": "auth0|58e43f45902b27174fc065bed71",
  "aud": "VaNkT5yOxGXMtdN7UVlKdFGy7daCGOJ0",
  "exp": 1493923035,
  "iat": 1493887035
}

```

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [May 5, 2017, 10:58am UTC](https://community.auth0.com/t/auth0-js-not-returning-the-correct-audience/6480/2 "2017-05-05T10:58:03Z")

</div>

Have you configured an API in Auth0 that corresponds to the `https://myapi.com` identifier?

---

<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 2, 2018, 5:53am UTC](https://community.auth0.com/t/auth0-js-not-returning-the-correct-audience/6480/3 "2018-03-02T05:53:41Z")

</div>


