T
T
Tati122019-05-12 12:03:53
API
Tati12, 2019-05-12 12:03:53

How to make a request to API with JWT?

I will be very grateful! I am a beginner front, js.
It is necessary to receive information from the site (API , JWT).
The site gave me a login and password for authorization ...
JWT generated.
Previously I worked with Api , but without token and in a rather simple format... How to make requests? How to authorize? Is it possible to do this in js?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2019-05-12
@vshvydky

if jwt is done according to the rules, the case is something like the following
POST /some/api/login body {login password}
response: {access_token, refresh_token, exp... }
you save tokens for yourself, usually access_token is a short key, it is updated via refresh_token at the corresponding point ( what bek came up with).
all requests that require verified access are made with the substitution of the received valid token in the headers, according to the rules, the header should be the following "Authorization": "bearer access_token
" it happened, you do a reactorization, and a repeated request to the server.
about the same way

N
Noir, 2019-05-12
@PolarBearGG

download postman and just make the request that you need, then copy the code and you're done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question