Laravel 8 tutorial - API authentication with Sanctum
HTML-код
- Опубликовано: 30 сен 2020
- In this laravel 8 API tutorial, we learn how secure api with laravel sanctum package and how to authenticate API with a simple way. This video is made by anil Sidhu in the English language.
Laravel restful API tutorial
Install and Config
Migration and Controller
Example with API
Test API
Interview Question for Sanctum
Simple and straight to the point. Thank you sir.
Great tutorial. Very easy to follow and nicely explained. Really helped me understand it all. Thanks.
Nicely Explained it and works perfectly. Thanks a lot.
Great job man. I love the way you are teaching. thank You So Much
Thank you so much sir. This works perfectly.
Thanks so much sir! I have really learned so much concerning the auth access tokens for authenticating APIs.
great tutorial man.. thank you.. keep up the good work..
cool tutorial sir.... thank you, it's very helpfully
Welcome
Very useful ... Thank a lot
Thanks, very good video, you are a crack !!!
Very wonderful video
Man you're great 😘😘
Thanks, you saved me❤
Thanks so much Anil
Just for information, if you are getting error 500 when user is unauthenticated just add header to a request - Accept : application/json, then you will get proper error 401. Also don't forget to revoke old tokens otherwise your table gets filled pretty quickly
Thanks!
how can i revoke old tokens
Thanks a lot man
@@hadesinferno813 could you explain how to revoke old tokens?
ok good it's working for me
how about when we see member data but only specific data when entering the token?
Sir sanctum or jwt which one better
Thanks sir
hii sir.. i like ur laravel videos and the way u teach but in this video u have'nt shown about member model, controller .. also will u please also upload a video for laravel 8 passport api as u uploaded for sanctum.
thanks sir
Sir i am facing a problem during instalationl the santum i am not getting some table name in date base after migration....in my system after run migrate command iam getting some error
why are you not using or setup passport ?
sir can you demonstrate this video without postman extension i mean live
nice
thanks for the video, how do you catch the error....incase you don't use the token
good
Is it possible to display api data into blade..
how can i show a message to user when they are not logged in but trying to fetch a secured url. Its always giving an error but how can i send custom error
সুন্দর
which is good this or passport package ???
Please make video about passport authentication
How can I bring the authorisation and the URL together?
All the code worked fine for me! But when I deployed in the live server, it just returns an unauthenticated error even after the successful login. Will you please help to solve the error?
Shouldn't your index function inside your UserController be declared public??
Like magic
I am not sure but what I understood is: Sanctum is used for Single Page Application which use sessions and validates users where as Passport is used when are communicating between different applications which uses oauth2. Please correct me if I am wrong
Sanctum allows both, sessions first and then API. But for Sanctum API authentication, instead of OAuth, it uses personal access tokens placed on header requests. If you need to expand/implement Mobile App access in the future that allows the use of accounts in 3rd party apps like FB, Twitter, etc. (all of which uses OAuth2), then use Passport. Sanctum doesn't provide OAuth2.
i can't see membercontroller , how can i look?
Hello, can you please tell or show a link to an example. how fashionable to get data with authentication not through postman but through JavaScript?
no link in description bro , where i can get link
Publish command k bd configurations or migrations add hni hn wo add ni horaen and then there is nothing to migrate. what to do?
If token is wrong I get 500 instead of 401.. Why?
thx .all's good. I forgo to add Accept: application/json to request header
How can we use jwt auth
Is this called REST apis?
Hey first comment
How to handle created token in Laravel as a header Authorization Bearer "Token"
Sir, why we must supply word 'Bearer' in the value for authorization in Headers. Why not can we just supply the token instead
This is just prefix, almost all token library require this prefix.
how we use sanctum in oracel db and change authincate table name
sir will you give me the link for role and permission in laravel using spatie or any else.
how to delete a token or logout?
*Uses documentation*
*Doesn't provide link to documentation*
I don't know what is wrong
What is difference of passport nd jwt md any know please explain me
I get error msg 'route login not defined' when opening protected page on a browser. i checked with auth::check and its logged in. i used xmlhttprequest and passed the credentials. the response returned true (based on auth::check) and i tried opening the protected page in a new tab in javascript. i have define route in authcontroller(tried both, get and post), just started to learn laravel, what wrong am i doing.
place the signin and login route outside the middleware group and pass the token in header
Sir Many times whenever i install the laravel and run migrate command it shows key id too long why?
same
go to AppServiceProvider.php and add these lines
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
this is not working in production server ...
its only worked when we run it with php artisan serve
how to delete api individual token or how to logout user kindle make it video on this
i wish he could explain how register function should be written seeder won't help me in the front end
Follow sanctum doc from laravel
Laravel k package Kitna hote h or kya kya krte hai..plzz explain
the token returned, i should store it, right ? ...... what if i'm working with roles and permissions ? ........ how do i check if that user has required privileges with just the token
@pwcodigo someone else recommended bouncer package
I have same your question! did you found answer for it
You can write a middleware to perform those checks
Source Code ?
you must to buy GX40 Official tools in leakfullz,
@11:48 no, not "right"...no link in here
I'm getting this Error
can u understand me im facig this error Column 'tokenable_id' cannot be null (SQL: insert into `personal_access_tokens` (`name`, `token`, `abilities`, `tokenable_id`, `tokenable_type`, `updated_at`, `created_at`) values (my-app-token, 02ce35258c68d034e644f636ddc9901541e9a4e10cf15279b7e5f2655443335b, ["*"], ?,
What's difference between Passport And Sanctum Packages
passport uses JWT based authentication.
@@cmm3338 what is JWT
@@jashanpreet832 JSON web token,
Ok can we use sanctum instead of passport
@@jashanpreet832 Depends on the type of application you are building, the short answer yes.. the actual answer, depends on your use case as to whether it is the best option or not. Not enough information. Passport is a full fledged Oauth implementation, sanctum just provides a token for authentication. If all you need is basic authentication to your 'api' routes, then yes.. Sanctum will work great.
Error: Call to undefined method stdClass::createToken()
I had the same problem and it turned out I didn't copy the 5:15 fragment of code inside User class
please do organize your channel because its waste too much time to search a relevant video and add links in every video like github link in this video
Very cool login, But where is registration? for dumb ones like me that need to see
How to add prefix in default /login & /register api in laravel sanctum ?
Ex. Default api are /login & /register
I want /api/login & /api/register
How to achieve this?
Also in /user api i am getting many fields like id,name,email,created_date
I just want name and email id
How to do that?
it is laravel not laravebel
this tutorials can not help any developer to improve in learning !
I really do not believe this tut has been watched for more than 50 k very bad technuiques are used .