0

I recently implement Axios in my react native app. The problem I am facing is whenever I add authorization header with the request, it returns 400 while the same request with same Auth token is working fine with Postman. What can be the issue?

axios.get(EndPointURL, {
        headers: {
            Authorization: BearerToken
        }
    })
    .then(result => {
        console.log(result);
    })
    .catch(reason => {
        console.log(
            reason
        );
    });
}
Ru Chern Chong
  • 3,692
  • 13
  • 33
  • 43
Usman Iftakhar
  • 278
  • 5
  • 17

1 Answers1

0

Are you sure that BearerToken is the same as the token you're using in PostMan? Seems to me you need you're not adding Bearer prefix that's required by OAuth2

Example:

headers: {
    Authorization: `Bearer ${BearerToken}`
}
Tareq El-Masri
  • 2,413
  • 15
  • 23