# Testing backend endpoints that require bearer token?

**URL:** <https://community.auth0.com/t/testing-backend-endpoints-that-require-bearer-token/100767>\
**Category:** JWT.io\
**Tags:** jwt, login\
**Created:** [February 17, 2023, 8:34pm UTC](https://community.auth0.com/t/testing-backend-endpoints-that-require-bearer-token/100767 "2023-02-17T20:34:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigpotato](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bigpotato/32/32722_2.png) [@bigpotato](https://community.auth0.com/u/bigpotato)\
**Post date:** [February 17, 2023, 8:34pm UTC](https://community.auth0.com/t/testing-backend-endpoints-that-require-bearer-token/100767/1 "2023-02-17T20:34:27Z")

</div>

Hi I am trying to test my backend API, which expects a valid auth0 access token.

What is the convention around this?  
Is there a way I can generate a token programmatically for a user with specific permissions without having to make an actual request to auth0? It’s against normal testing standards to have to make external API requests because it means it’s no longer self contained.

Or do I have to hardcode an actual access token for a real user?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [February 17, 2023, 9:56pm UTC](https://community.auth0.com/t/testing-backend-endpoints-that-require-bearer-token/100767/3 "2023-02-17T21:56:56Z")

</div>

Hi there @bigpotato!

Good question - You’ll need to make an actual request to get a valid Access Token. In my experience, most will go the route of configuring their application in Auth0 to allow the Resource Owner Password grant and use the auth API debugger extension to grab a “test” token.

> [@Is there an easy way to get a user access token for testing?](https://community.auth0.com/t/is-there-an-easy-way-to-get-a-user-access-token-for-testing/73170/3):
>
> Hi @aryou, Welcome to the Auth0 Community! We don’t have a user impersonation feature, if you are trying to get tokens for existing users for which you do not know their password. If you want to get a token for a test user, you could use the [Authentication API Debugger Extension](https://auth0.com/docs/extensions/authentication-api-debugger-extension), set up the [Resource Owner Password Flow](https://auth0.com/docs/authorization/flows/resource-owner-password-flow) (this allows you to directly exchange username/password for a token without the login widget), or use the “Try Connection” feature with dev tools to inspect the request and gra…

Hope this helps!

---

<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:** [April 21, 2023, 9:56pm UTC](https://community.auth0.com/t/testing-backend-endpoints-that-require-bearer-token/100767/4 "2023-04-21T21:56:50Z")

</div>

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