Answer the question
In order to leave comments, you need to log in
How to properly use acces token in Laravel and Vue.js?
I have a laravel backend. And I write the client on vue.js. My client sends a request to the server via vue-resource. Router sends to the controller, the controller checks if the user is authorized, he gives data from the database, if not, then he gives an error and the client is already processing what has come. So far this is the only way I've come up with.
But many materials use acces tokens. I've looked at a lot of them but I still can't figure out exactly how it works.
Tell me how to use tokens correctly, for what, etc.
Answer the question
In order to leave comments, you need to log in
Look towards Laravel JWT Auth . Trivial solution for authorization in case of REST API. There is good documentation there.
Checking each time in the controller whether the user is authorized is not worth it. There is Middleware for this.
Access tokens are needed to identify the user (request) by the server. It can be a CSRF token, a session parameter, a Bearer token, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question