# How to get tokens to test our APIs from Postman?

**URL:** <https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [October 2, 2023, 9:56am UTC](https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541 "2023-10-02T09:56:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaonan.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/xiaonan.zhang/32/51298_2.png) [@xiaonan.zhang](https://community.auth0.com/u/xiaonan.zhang)\
**Post date:** [October 2, 2023, 9:56am UTC](https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541/1 "2023-10-02T09:56:32Z")

</div>

Our mobile app project has a Quarkus backend and an Expo frontend.  
The frontend SDK gets access token from Auth0 and sends API calls to the backend.  
But the token from Auth0 is an opaque token so the backend is configured to validate the token with Auth0’s user-info endpoint.

Everything works as expected when requests are sent from the frontend UI. However, we need a way to test our API without using the frontend UI. As the opaque token can only be generated from the frontend SDK, we are not sure what is the best way to test the API with Postman.

Any suggestions or recommendations please? Thanks in advance!

---

<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:** [October 2, 2023, 6:11pm UTC](https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541/3 "2023-10-02T18:11:53Z")

</div>

Hi @xiaonan.zhang,

Welcome to the Auth0 Community!

If you have been getting an opaque access token, it means that the `audience` parameter was not included in the login request.

Given that, I recommend passing in the `audience` parameter, which references your API identifier, so you can a JWT access token to be used against your API.

```auto
https://testrueben.auth0.com/authorize?
    response_type=code&
    client_id=HICy2jI4atNE6xjgFr7VrYYoUyiB5dbI&
    redirect_uri=https://youtube.com&
    scope={scope}&
    audience={apiAudience}&
    state={state}

```

Reference:

- [Call Your API Using the Authorization Code Flow](https://auth0.com/docs/authorization/flows/call-your-api-using-the-authorization-code-flow)
- [Get Management API Access Tokens for Single-Page Applications](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-tokens-for-single-page-applications)

Please let me know if you have any questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![xiaonan.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/xiaonan.zhang/32/51298_2.png) [@xiaonan.zhang](https://community.auth0.com/u/xiaonan.zhang)\
**Post date:** [October 2, 2023, 7:18pm UTC](https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541/4 "2023-10-02T19:18:14Z")

</div>

Thanks very much for your reply!

The goal is to test our backend APIs with Postman so I’ve tried the Resource Owner Password Flow. It works if the Auth0 application type is set to “Regular Web App”. A normal JWT can be retrieved by calling `https://<tenant>.auth0.com/oauth/token`.

However in our case the Auth0 application type is “Native” which does not support the Resource Owner Password Flow. Do we need to create two applications, “Native” and “Regular Web App”, and configure our server with the credentials from both of them?

Regarding the opaque token, is it recommended to use opaque token or JWT with the audience configured?

---

<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:** [October 2, 2023, 7:34pm UTC](https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541/5 "2023-10-02T19:34:10Z")

</div>

Hi @xiaonan.zhang,

Thanks for the reply.

You will need the user to authenticate as usual with the `audience` parameter in the login request.

Is there a reason you are using Resource Owner Password grant flow instead of the [authorization code grant flow](https://auth0.com/docs/authorization/flows/call-your-api-using-the-authorization-code-flow)?

> [@xiaonan.zhang](#):
>
> Regarding the opaque token, is it recommended to use opaque token or JWT with the audience configured?

You will need to get a JWT access token to access your API. The opaque access token is only meant to be used against the [/userinfo endpoint.](https://auth0.com/docs/api/authentication#user-profile)

 ![image](https://global.discourse-cdn.com/auth0/original/3X/7/c/7cddf4677cae8bba34afb64af586c756086272a6.png)  
(Reference: [Get Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/get-access-tokens))

---

<div class="post-metadata">

**Author:** ![xiaonan.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/xiaonan.zhang/32/51298_2.png) [@xiaonan.zhang](https://community.auth0.com/u/xiaonan.zhang)\
**Post date:** [October 2, 2023, 7:50pm UTC](https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541/6 "2023-10-02T19:50:46Z")

</div>

The sign-in is done in the frontend code so in our case, the React Native code calls `auth0.authorize()`. Then the React Native code calls `auth0.getCredentials()` for retrieving a token (opaque if no audience set in the authorize).

After that, the token is included in the REST request `Authorization` header as a Bearer token for calling our serverside APIs.

Our server is Quarkus. Once the request is received, it goes to Auth0’s userinfo endpoint for validating the token and retrieve the user info.

Our backend server is only for validating tokens so no login actions performed directly on it. Do you recommend to always set the audience to avoid using opaque tokens based on the above?

Token types aside, we need to test our serverside APIs via Postman. So in this case, the frontend code is not involved and we need a way to get a token to call our APIs. But the Auth0 “Native” type application does not support Resource Owner Password grant flow.

---

<div class="post-metadata">

**Author:** ![xiaonan.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/xiaonan.zhang/32/51298_2.png) [@xiaonan.zhang](https://community.auth0.com/u/xiaonan.zhang)\
**Post date:** [October 2, 2023, 8:00pm UTC](https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541/7 "2023-10-02T20:00:46Z")

</div>

Attached a diagram for detailing the flow

 ![Auth0 flow (1)](https://global.discourse-cdn.com/auth0/original/3X/3/2/32ec1568c22814e8aec762d4ff6704f14cfb06e8.png)

---

<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:** [October 10, 2023, 4:28pm UTC](https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541/8 "2023-10-10T16:28:13Z")

</div>

Hi @xiaonan.zhang,

Thanks for following up.

For testing your APIs in Postman, you will need to pass an `audience` parameter in your login request. This is intended to create a JWT access token to be used against your API. For example:

```auto
auth0.authorize({
    scope: 'openid profile email', // Specify the desired scopes
    audience: 'your-api-audience', // Specify the API audience
    // Add any additional parameters as needed
  })

```

> [@xiaonan.zhang](#):
>
> Our backend server is only for validating tokens so no login actions performed directly on it. Do you recommend to always set the audience to avoid using opaque tokens based on the above?

Yes, if you intend to use the token in the future against your API. Let me also add that you can get most of the information found in your opaque access token as you do in your JWT access token. If there are any attributes missing, you could always append them to your JWT access token as custom claims.

See [Adding custom claims to tokens](https://community.auth0.com/t/adding-custom-claims-to-tokens/84590).

> [@xiaonan.zhang](#):
>
> But the Auth0 “Native” type application does not support Resource Owner Password grant flow.

You will need to use the [Authorization Code flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-authorization-code-flow) or the [Client Credentials flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-client-credentials-flow).

Thanks,  
Rueben

---

<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:** [October 24, 2023, 4:28pm UTC](https://community.auth0.com/t/how-to-get-tokens-to-test-our-apis-from-postman/117541/9 "2023-10-24T16:28:35Z")

</div>

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