# How to get Auth0 token from outside React components in this specific case?

**URL:** <https://community.auth0.com/t/how-to-get-auth0-token-from-outside-react-components-in-this-specific-case/77612>\
**Category:** Get Help\
**Tags:** jwt, auth0\
**Created:** [February 3, 2022, 4:04pm UTC](https://community.auth0.com/t/how-to-get-auth0-token-from-outside-react-components-in-this-specific-case/77612 "2022-02-03T16:04:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimitar.a](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dimitar.a/32/12759_2.png) [@dimitar.a](https://community.auth0.com/u/dimitar.a)\
**Post date:** [February 3, 2022, 4:04pm UTC](https://community.auth0.com/t/how-to-get-auth0-token-from-outside-react-components-in-this-specific-case/77612/1 "2022-02-03T16:04:40Z")

</div>

I switched to Auth0 authentication in my React app. After I authenticate with Auth0 my app routes to /dashboard component which needs to get data from my API to which I need to authenticate with the access token from Auth0. But, the request fails as I have no Authorization header set in my request. I need to set an Authorization header for all of the requests happening after the authentication with a value of “Bearer accessToken”.

What is the best practice to get this flow working?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 3, 2022, 11:17pm UTC](https://community.auth0.com/t/how-to-get-auth0-token-from-outside-react-components-in-this-specific-case/77612/3 "2022-02-03T23:17:23Z")

</div>

Hi @dimitar.a,

Welcome to the Auth0 Community!

Have you seen our [Auth0 React SDK Quickstarts: Call an API](https://auth0.com/docs/quickstart/spa/react/02-calling-an-api)?

This shows how we recommend setting up fetching and using an access token in react.

---

<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 18, 2022, 11:18pm UTC](https://community.auth0.com/t/how-to-get-auth0-token-from-outside-react-components-in-this-specific-case/77612/4 "2022-02-18T23:18:21Z")

</div>

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