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

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?

Hi @dimitar.a,

Welcome to the Auth0 Community!

Have you seen our Auth0 React SDK Quickstarts: Call an API?

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