P
P
Pavel Zhukau2016-07-05 23:22:15
JavaScript
Pavel Zhukau, 2016-07-05 23:22:15

How to do authentication using API?

Good evening everyone, I can not understand the principle of authorization in js. I send login and password to the server side (laravel, jwt) in response I get a token. Store the token in localstorage? and in the future, when making requests to the server, assign it to the header of the request in Authorization ? But what to do, the token is not eternal, when to update it? I can't understand how it works. I tried to google about how token-based authentication works, but found nothing. Please put me on the right path.
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Arushanov, 2016-07-06
@daruwanov

The simplest yes ... login password, dragged the token. Token for each request in the header. When the token is out of date - then send the user to the login page. Or use refresh token. And in general, read about OAuth

M
Maxim, 2016-07-06
@maxfarseer

I join the answer above, and add that I like the Auth0 materials (and the authorization form itself is very good!). About refresh token from them - here (eng)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question