Using Axios to call an external API secured by Auth0 using JWT

Hello,
I am struggling with calling my external back-end API with a Auth0 Bearer token for authentication.

I found this post about the same thing, but this post is about the react SDK and I’m using the NextJs SDK

I also created a StackOverflow post about this

Feel free to help me out :slight_smile:

Thankyou!

Hi @jmunckhof,

Welcome to the Auth0 Community!

What library are you using to make requests (axios, fetch, etc.)?

Sorry for not mentioning that, I’m using Axis for fetching. But if I need to switch to another library to fix this, That’s Ok

Just to be clear, I want to send a API request to my back-end secured by Auth0 and automatically add the Bearer token to every request in the frontend.

I should probably doing something with Axios interceptor or custom hook but I need the req and res variables for the getAccessToken from @auth0/nextjs-auth. I mentioned the other article about this problem, But he is using the React SDK where you don’t need the req and res and call getAccessTokenSilently which I think is removed in the NextJS SDK

Any updates here? I am facing the same challenge. when using auth0-react I was able to use getAccessTokenSilently But with auth0-next I don’t have access to the accessToken