I had to add a new header variable key: X-XSRF-TOKEN, value: {{xsrf-cookie}} I can also suggest you add key: Accept, value: application/json (so that you actually see validation errors).
i use Laravel11 sanctum session (not token) Login and logout (endpoints) are working correctly when called from postman but when I call other api end points it gives me 401 unauthorized
Yeah, I was getting the page expired situation too. The whole csrf token/prescript section got glossed over and that was apparently pretty important. Adding the X-XSRF-TOKEN headed did get past the expired page, but it still doesn't write to the DB and just returns 204 no content when I submit the register endpoint.
It works, thanks. However there is a small problem. If I try to access the resources directly without providing the bearer token on api route, it tries to redirect to login route instead of returning unauthorized error. How do I fix it?
My friend, here's a piece of advice. If you're going to do something, do it all. Don't skip steps, because it's not just geniuses who want to learn how to code an API with Sanctum. There are a lot of students who are just starting to learn and what you're doing is reckless and this video should be taken down. Because it's wasting people's time. Or make another video and explain the entire process you used to create the connections in Postman. It's not enough to know how to do it and brag about it, you have to do it the right way! Excuse my rant, but you need to be criticized too and not just praised. Your attitude in sharing was excellent but the way you did it was a disaster!
I am so sorry to hear this and I really admire you to be straightforward and helping me improve. I will soon make a detail video on this topic. Thanks a lot for being honest :)
CSRF token mismatch. even the XSRF is set
when i try it, i get error "Page Expired" on register, any have same problem?
I had to add a new header variable key: X-XSRF-TOKEN, value: {{xsrf-cookie}}
I can also suggest you add key: Accept, value: application/json (so that you actually see validation errors).
@@thomaswikman2239 same thing, inserting the parameter in the header and the value doesn't change, too bad
i use Laravel11 sanctum session (not token) Login and logout (endpoints) are working correctly when called from postman but when I call other api end points it gives me 401 unauthorized
How did you config csrf token in Laravel?
not found this tutorial, when i try it, i get error "Page Expired"
Yeah, I was getting the page expired situation too. The whole csrf token/prescript section got glossed over and that was apparently pretty important.
Adding the X-XSRF-TOKEN headed did get past the expired page, but it still doesn't write to the DB and just returns 204 no content when I submit the register endpoint.
It works, thanks. However there is a small problem.
If I try to access the resources directly without providing the bearer token on api route, it tries to redirect to login route instead of returning unauthorized error. How do I fix it?
Method 1:
Add header: Accept: application/json
Method 2:
Manually validate Login using the Auth class
@@kamauleao thanks
what extension do you use for auto complete code?
what is the code suggestion extension you use for VSCode?
if you found the answer, please share it. Thanks
I am using Github copilot
@@TheAspectDev found
In docker laradock I always get 401 unauthorized. How do I fix it to make it work?
It really helps me a lot. Need more videos about the basics of Laravel API.
Please which extensions do you use 🙏
Can you please explain the csrf token part? I always get code 419 error
Me too
i would also like to know how you config csrf token.And can you create a project in laravel 11 for booking system
When I try without login it redirect to login page
Method 1:
Add header: Accept: application/json
Method 2:
Manually validate Login using the Auth class
good hindia continue😍😍
Thanks for this tutorial
My friend, here's a piece of advice. If you're going to do something, do it all. Don't skip steps, because it's not just geniuses who want to learn how to code an API with Sanctum. There are a lot of students who are just starting to learn and what you're doing is reckless and this video should be taken down. Because it's wasting people's time. Or make another video and explain the entire process you used to create the connections in Postman. It's not enough to know how to do it and brag about it, you have to do it the right way! Excuse my rant, but you need to be criticized too and not just praised. Your attitude in sharing was excellent but the way you did it was a disaster!
I am so sorry to hear this and I really admire you to be straightforward and helping me improve. I will soon make a detail video on this topic. Thanks a lot for being honest :)
Спасибо!
superb, need more videos , i am basics Learner
왜 망할 과정들을 빼먹고 설명하는거야... Postman에 Register, Login에 추가로 들어가는 Header 파라미터는 대체 뭐야..
best lesson bro! tnx so much!