T
T
Tyrellname2018-12-07 02:19:06
JSON Web Token
Tyrellname, 2018-12-07 02:19:06

How should the client set the http Authorization: token when making a request to the server?

I can through curl or postman by specifying the token in the header Authorization: token
curl -X GET -H "Authorization: token" localhost:3000/private
But how do you get authorized in a real application? If the token is specified in the cookie, how can I get the cookie when the client requests /get and immediately put it in the header authorization: token?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Pautov, 2018-12-07
@Tyrellname

1) Request authorization
2) After successful authorization, get a token
3) Save the token on the client in a cookie
4) On subsequent requests to the server, specify the authorization header with the token taken from the browser cookie in each request
Done!
PS The header with the token must be passed each time in each client request to the server if you need to receive data that is available only to authorized users

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question