# \[SPA + API\] Can NOT Get Audience Correct

**URL:** <https://community.auth0.com/t/spa-api-can-not-get-audience-correct/20183>\
**Category:** Get Help\
**Tags:** spa, jwt, api, audience, auth0\
**Created:** [January 18, 2019, 7:29am UTC](https://community.auth0.com/t/spa-api-can-not-get-audience-correct/20183 "2019-01-18T07:29:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsu317](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jsu317](https://community.auth0.com/u/jsu317)\
**Post date:** [January 18, 2019, 7:29am UTC](https://community.auth0.com/t/spa-api-can-not-get-audience-correct/20183/1 "2019-01-18T07:29:03Z")

</div>

Goal: Have SPA + API Work.

I have followed the tutorial to create one API and one Application. I have tried many methods to get the JWT, so that I can make API calls from client Javascript.  
The problem is no matter how I set _audience_ in my Auth0.WebAuth parameters, or direct http call. The return value for audience is always the same ClientID.

Here is the link I tried to make a request to get authorized for the id\_token.

_[Edited for tenant privacy]_

I must have missed something, but after over 12 hours of work. I have run out of woods.  
Please help. Thank you.

Regards.

---

<div class="post-metadata">

**Author:** ![jsu317](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jsu317](https://community.auth0.com/u/jsu317)\
**Post date:** [January 18, 2019, 4:20pm UTC](https://community.auth0.com/t/spa-api-can-not-get-audience-correct/20183/2 "2019-01-18T16:20:23Z")

</div>

Here is the access\_token I got from the request.

_[edit for privacy]_

---

<div class="post-metadata">

**Author:** ![kim.maida](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kim.maida/32/17888_2.png) [@kim.maida](https://community.auth0.com/u/kim.maida)\
**Post date:** [January 21, 2019, 1:59pm UTC](https://community.auth0.com/t/spa-api-can-not-get-audience-correct/20183/3 "2019-01-21T13:59:56Z")

</div>

Hello! The issue that I am seeing is that you are not requesting an access token, you’re requesting only an ID token. By [specification definition](https://openid.net/specs/openid-connect-core-1_0.html#IDToken), the audience of an ID token will _always_ be the client ID. In order to request an access token for API authorization, you can format your your WebAuth instance like so:

```
new auth0.WebAuth({
  clientID: YOUR_CLIENT_ID,
  domain: YOUR_DOMAIN,
  responseType: 'token id_token',
  audience: 'YOUR_AUTH0_API_IDENTIFIER',
  ...[etc]

```

Requesting `token id_token` as the `responseType` will ensure that you receive an access token with the appropriate audience for your API in addition to the ID token. The WebAuth instance’s `audience` should match the identifier for the API that you set up at [https://manage.auth0.com/#/apis](https://manage.auth0.com/#/apis)

I hope this helps! Please let us know if you have any further questions or run into issues.

---

<div class="post-metadata">

**Author:** ![jsu317](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jsu317](https://community.auth0.com/u/jsu317)\
**Post date:** [January 25, 2019, 5:36pm UTC](https://community.auth0.com/t/spa-api-can-not-get-audience-correct/20183/4 "2019-01-25T17:36:36Z")

</div>

Thank you for the reply. This really helped me out.

---

<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:** [February 9, 2019, 5:36pm UTC](https://community.auth0.com/t/spa-api-can-not-get-audience-correct/20183/5 "2019-02-09T17:36:36Z")

</div>

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