# Authorization code flow returns opaque token instead of JWT even though audience is set

**URL:** <https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951>\
**Category:** Get Help\
**Tags:** jwt, api\
**Created:** [November 11, 2021, 12:11am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951 "2021-11-11T00:11:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![brady.dean](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brady.dean/32/12851_2.png) [@brady.dean](https://community.auth0.com/u/brady.dean)\
**Post date:** [November 11, 2021, 12:11am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/1 "2021-11-11T00:11:52Z")

</div>

I’m trying to request an access token for an api using the authorization code flow. I’m using Postman’s built in access token getter. The application it’s authenticating for is an SPA. I have all the urls set and also an audience, but it receives an opaque token instead of a JWT. The Auth0 docs say a JWT should be returned if I request an audience.

Anyone know what might be the problem?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 11, 2021, 12:44am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/3 "2021-11-11T00:44:10Z")

</div>

Hi @brady.dean,

Welcome to the Auth0 Community!

I understand that you’ve been obtaining an opaque token instead of a JWT access token.

> [@brady.dean](#):
>
> The Auth0 docs say a JWT should be returned if I request an audience.

Yes, that is correct. You will need to specify the `audience` parameter to get a JWT access token. Without specifying an `audience` parameter will return an opaque token with the information from the `/userinfo` endpoint. This is consistent with our [Control Access Token audience](https://auth0.com/docs/security/tokens/access-tokens/get-access-tokens#control-access-token-audience) documentation.

I have just tested this myself and can confirm that including the `audience` returns a JWT token, whereas excluding the `audience` returns an opaque token. This is working as expected.

In this case, I recommend that you make sure that the /authorize request when using Postman recognizes the audience parameter or the changes you made to your request.

Please let me know how this goes for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![brady.dean](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brady.dean/32/12851_2.png) [@brady.dean](https://community.auth0.com/u/brady.dean)\
**Post date:** [November 11, 2021, 1:27am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/4 "2021-11-11T01:27:54Z")

</div>

Thanks for double checking with the audience parameter. I’ll try to see if I can find more information about Postman.

---

<div class="post-metadata">

**Author:** ![brady.dean](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brady.dean/32/12851_2.png) [@brady.dean](https://community.auth0.com/u/brady.dean)\
**Post date:** [November 11, 2021, 1:33am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/5 "2021-11-11T01:33:48Z")

</div>

The Postman console is showing the audience set in the request body to /oauth/token.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 11, 2021, 1:50am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/6 "2021-11-11T01:50:41Z")

</div>

Hi @brady.dean,

Thank you for your responses!

I believe you’ll need to adjust the `audience` parameter when you make the `/authorize` request to obtain the authorization code.

For example:

```auto
https://YOUR_DOMAIN/authorize?
    response_type=code&
    client_id=YOUR_CLIENT_ID&
    redirect_uri=https://YOUR_APP/callback&
    scope=SCOPE&
    audience=API_AUDIENCE&
    state=STATE

```

In this request, please specify the `audience` parameter with your API identifier. Then in the response, you’ll obtain an **authorization code** that will allow you to use with the `/oauth/token` endpoint to obtain the **Access Token** as a JWT.

Please let me how this works out.

Thank you.

---

<div class="post-metadata">

**Author:** ![brady.dean](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brady.dean/32/12851_2.png) [@brady.dean](https://community.auth0.com/u/brady.dean)\
**Post date:** [November 11, 2021, 2:01am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/7 "2021-11-11T02:01:43Z")

</div>

Postman doesn’t seem to be log the request to /authorize. I don’t know what it’s sending there.

---

<div class="post-metadata">

**Author:** ![brady.dean](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brady.dean/32/12851_2.png) [@brady.dean](https://community.auth0.com/u/brady.dean)\
**Post date:** [November 11, 2021, 2:10am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/8 "2021-11-11T02:10:13Z")

</div>

I’ll take your word that Auth0 is handling the requests correctly. It seems to be an issue with Postman. I filed a bug report for the logging so hopefully that uncovers a deeper issue.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 11, 2021, 2:28am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/9 "2021-11-11T02:28:59Z")

</div>

Hi @brady.dean,

I am unsure what is happening on your side with Postman. But have you followed our [Call Your API Using the Authorization Code Flow](https://auth0.com/docs/authorization/flows/call-your-api-using-the-authorization-code-flow) docs?

Personally, I have managed to get this to work by doing the following:

1. Open a web browser and put the `/authorize` request in the URL.  

2. Login with a user that has access to login to the app

3. Check the Network Activity and the callback URL trace

4. The response should follow this format `https://YOUR_APP/callback?code=AUTHORIZATION_CODE&state=xyzABC123`  

5. I copy this code carefully and paste it in Postman with the `/oauth/token` endpoint and retrieve my Access Token.

This might be worth a try just to rule out that something is happening with Postman.

Thanks!

---

<div class="post-metadata">

**Author:** ![brady.dean](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brady.dean/32/12851_2.png) [@brady.dean](https://community.auth0.com/u/brady.dean)\
**Post date:** [November 11, 2021, 2:38am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/10 "2021-11-11T02:38:52Z")

</div>

I tried it your manual way and it worked perfectly requesting the audience at /authorize.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 11, 2021, 2:46am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/11 "2021-11-11T02:46:30Z")

</div>

Hi @brady.dean,

Great! I’m happy to hear this little manual hack works.

I hope this workaround will be adequate for you to carry on your development.

Please let me know If you have any more questions or concerns. I’d be happy to help.

Thank you!

---

<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:** [November 26, 2021, 2:46am UTC](https://community.auth0.com/t/authorization-code-flow-returns-opaque-token-instead-of-jwt-even-though-audience-is-set/72951/12 "2021-11-26T02:46:56Z")

</div>

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