# Opaque token returned for hosted lock with audience param

**URL:** <https://community.auth0.com/t/opaque-token-returned-for-hosted-lock-with-audience-param/9521>\
**Category:** Get Help\
**Tags:** api-authorization, access-token\
**Created:** [February 16, 2018, 6:34pm UTC](https://community.auth0.com/t/opaque-token-returned-for-hosted-lock-with-audience-param/9521 "2018-02-16T18:34:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark06](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mark06/32/24563_2.png) [@Mark06](https://community.auth0.com/u/Mark06)\
**Post date:** [February 16, 2018, 6:34pm UTC](https://community.auth0.com/t/opaque-token-returned-for-hosted-lock-with-audience-param/9521/1 "2018-02-16T18:34:14Z")

</div>

Hi,  
I’m having trouble getting an access\_token for my API using the hosted Lock. I’ve specified the audience as follows:

```
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
  auth: {
    redirectUrl: config.callbackURL,
    responseType: (config.internalOptions || {}).response_type ||
      config.callbackOnLocationHash ? 'token' : 'code',
    params: config.internalOptions,
    audience: 'my_api_identifier'
  },

```

Which sends the request:

```
https://myapp.auth0.com/authorize?client_id=1yMOhyS....
&response_type=token%20id_token
&redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Fcallback
&audience=my_api_identifier
&connection=Username-Password-Authentication
&login_hint=mark%40email.com
&nonce=6wcybvcAB...
&state=uxnbKWq7h...
&scope=openid%20profile
&_csrf=deprecated
&protocol=oauth2
&auth0Client=eyJuYW1l...
&_intstate=true

```

But, event though the `audience` param is set correctly, I just get an opaque access token back rather than the JWT I need to access `my_api_identifier`.

I also tried the request with a bogus audience, and the authentication didn’t fail, so it’s my guess that some other parameters are causing the audience to be ignored entirely.

Any ideas?

---

<div class="post-metadata">

**Author:** ![ricardo.batista](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ricardo.batista/32/7711_2.png) [@ricardo.batista](https://community.auth0.com/u/ricardo.batista)\
**Post date:** [February 16, 2018, 6:51pm UTC](https://community.auth0.com/t/opaque-token-returned-for-hosted-lock-with-audience-param/9521/2 "2018-02-16T18:51:24Z")

</div>

You shouldn’t be setting the `audience` in the hosted login page, it should be set in your `auth0.WebAuth` object that makes the original authorization request.

Your hosted login page code should look like:

```
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
   auth: {
     redirectUrl: config.callbackURL,
     responseType: (config.internalOptions || {}).response_type ||
       config.callbackOnLocationHash ? 'token' : 'code',
     params: config.internalOptions
   },

```

And your WebAuth request should be:

```
var webAuth = new auth0.WebAuth({
  domain: {YOUR_AUTH0_DOMAIN}, 
  clientID: {CLIENT_ID},
  audience: {API_AUDIENCE},
  redirectUri: {CALLBACK_URL}, 
  scope: 'openid profile',
  responseType: 'token id_token'
});
webAuth.authorize();

```

This will give you a JWT access token. Also note that [when the audience is /userinfo] ([https://auth0.com/docs/tokens/access-token#access-token-format](https://auth0.com/docs/tokens/access-token#access-token-format)), an opaque token will always be issued.

---

<div class="post-metadata">

**Author:** ![Mark06](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mark06/32/24563_2.png) [@Mark06](https://community.auth0.com/u/Mark06)\
**Post date:** [February 16, 2018, 7:08pm UTC](https://community.auth0.com/t/opaque-token-returned-for-hosted-lock-with-audience-param/9521/3 "2018-02-16T19:08:27Z")

</div>

Hey Ricardo, ah yes, I should have thought to look into the angular docs as well. I was looking at this documentation [Lock Configuration Options](https://auth0.com/docs/libraries/lock/v11/configuration#audience-string-) and trying to figure it out from the chrome debugger.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 27, 2019, 10:34am UTC](https://community.auth0.com/t/opaque-token-returned-for-hosted-lock-with-audience-param/9521/4 "2019-08-27T10:34:37Z")

</div>


