Answer the question
In order to leave comments, you need to log in
Passport problem?
How to make this work properly ? CreateFreshApiToken
connected
Now, when I send a request to / test (that is, to "web"), authentication goes as it should:
Auth::check(); // true
Auth::user(); // User model
Auth::check(); // false
Auth::user(); // null
Cookie: laravel_token=eyJpdiI6IjRnY1...
Answer the question
In order to leave comments, you need to log in
Because you need to read the doc, it is also written there in an understandable language that CreateFreshApiToken generates a token and puts it in cuckoo. But this does not mean that he does everything for you. You need to get a token from the cookie at the front and send it with the behavior header.
You need to use this type
let bearer = Cookies.get('access_token');
if (bearer) {
window.axios.defaults.headers.common['Authorization'] = bearer
}
Konstatin gave you the right tip, which would be good for the doc to read.
But the less CreateFreshApiToken generates a token and puts it in ku-ku - right.
You will have to write a middleware that checks the x-csfr-token if the request comes from a site (api - oriented system). If an external site, then only through a token. The internet is full of information on how to do this. But since you are asking such a question, you do not understand how ouath2 is. I highly recommend spending 30 minutes of your life on this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question