Answer the question
In order to leave comments, you need to log in
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
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question