X-Auth-Token in Headers


#1

Hi all,

I am trying add Auth Token which I am getting as response data when i successfully logged-in on to the Http headers for others Services inside the App but I am unable to add it, I am trying to add this token to the http headers just like how we add Content-type in headers in Ionic 2 Or Ionic 3. Please help me out any suggestions, examples, demo video anything will be better

Thanks in advance


#2

Angular Http client docs.


#3

Hi @rapropos,

Thanks for your reply, I gone through Angular Doc which you sent me, But I am not seeing any content related to Token


#4

If you want to implément token I invite you to check jwt
To put a header it is the same as content type
The “common rule” is to put it in Authorization header like
Content-type : application/json
Authorization : Bearer yourtokenhere

However this is just a good practice. As you will implement it on app and server you can call this header “foo” or “miammiam” if you want.


#5

Thanks @speedflyer,
I will go through the jwt


#6

That is the correct way.

Why doesn’t it work?
Are you getting any errors?


#7

Ya I also believe that its a correct way and ya I am getting Error Message something like this
XMLHttpRequest cannot load http://someUrl. Response for preflight has invalid HTTP status code 401.
I have found on StackOverflow Answer regarding this issue, and it say that Its an Back-End issue.


#8

It is a back-end issue. The server isn’t dealing with CORS preflights correctly.