Authorization not working in Ionic2


#1

Hello everyone,
I’m trying to authenticate in ionic3. It works fine in postman.

In Ionic i get an 403, no token provided This is the code.

I think I’m doing something wrong with headers, i Just don’t know what.
Ps. my nodejs backend is based on this tutorial:

Who can help me?


#2

Did you remote debug the problem on the device already?
Follow these instructions here to debug the problem in Safari dev tools:
https://ionic.zone/debug/remote-debug-your-app#ios
Follow these instructions here to debug the problem in Chrome dev tools:
https://ionic.zone/debug/remote-debug-your-app#android
Look at the console and network tabs for errors.


#3

In your code you define a header “Authorization” with value “x-access-tokeneyJHbGc…”. Compare that to Postman.


#4

Wel if you mean I have to add an space (stupid me) I offcourse did that already but that doesn’t work. Still thinking there’s something else wrong with the headers


#5

No, I mean that the header is called “Authorization” right now but should be called “x-access-token” and have only the JWT token as a key, not more.


#6

You’re right.
Thank you very much