I have a protected router , with withApiAuthRequired and I need to call it from an other api which also have withApiAuthRequired. but I get :
{
error: 'not_authenticated',
description: 'The user does not have an active session or is not authenticated'
}
Do I have to pass a token with the fetch request like this? headers: {Authorization: Bearer ${accessToken}}
this did not work btw.
Yes, when you have APIs that are protected with Auth0’s withApiAuthRequired, you need to ensure that the access token is included in the request to authenticate the user.
By including the access token in the Authorization
header of the fetch
request, you can authenticate the user when calling a protected API that also requires authentication. Ensure that the accessToken
variable contains a valid, non-expired access token obtained from the initial authentication process
@pratyush.pandey, this did not work for me either. I tried:
headers: {Authorization: Bearer ${accessToken}}
@rezgui.aziz, did you ever find a solution for this?