Token Authentication - RESTful API with Laravel - 07

  Рет қаралды 84,248

Atif Naseem

Atif Naseem

Күн бұрын

Пікірлер: 149
@psychog_ax
@psychog_ax Жыл бұрын
Thank youu! super helpful! this video is amazing!
@AtifNaseem
@AtifNaseem Жыл бұрын
You're so welcome!
@nohelsolares3328
@nohelsolares3328 3 жыл бұрын
Thak you for this tutorial save my life hehehehehehehehhe
@AtifNaseem
@AtifNaseem 3 жыл бұрын
great
@M0stwan1eD
@M0stwan1eD 5 жыл бұрын
In Laravel 6.x install "laravel/ui" via composer and run "php artisan ui:auth" instead of make:auth
@AtifNaseem
@AtifNaseem 5 жыл бұрын
you are right in Laravel 6 php artisan ui:auth works
@saddamsagar2023
@saddamsagar2023 4 жыл бұрын
why we need make:auth though we just need to create a middleware and register it to kernel to perform.
@AtifNaseem
@AtifNaseem 4 жыл бұрын
You are right. Actually I was planning to initiate something else but I postponed.
@sumanprajapati1283
@sumanprajapati1283 4 жыл бұрын
awesome simple way to explain ...thanks
@AtifNaseem
@AtifNaseem 4 жыл бұрын
Glad you liked it
@RindiBudiaramdhan040490
@RindiBudiaramdhan040490 4 жыл бұрын
can we use multi authentication? 1. for our website (already use JWTToken) 2. For another website who want sync data from my website (???) help ty
@AtifNaseem
@AtifNaseem 4 жыл бұрын
Yes you can.
@seanrald0513
@seanrald0513 5 жыл бұрын
I followed the tutorial but when i test to postman i get App key not found?? Please Help
@AtifNaseem
@AtifNaseem 5 жыл бұрын
Please check the AuthKey.php $token = request()->header('App-Key'); use Camel Case with the dash instead of the underscore.
@cseshahriar
@cseshahriar 5 жыл бұрын
@@AtifNaseem I felt the same problem and solve it, Thanks
@makavelli646
@makavelli646 4 жыл бұрын
for ppl how still get this error Please check the AuthKey.php change $token = $request->header('App-Key'); to $token = $request->get('App-Key');
@andidarusman8408
@andidarusman8408 4 жыл бұрын
thanks a lot
@nickcourage7059
@nickcourage7059 4 жыл бұрын
For some reason, including an underscore in the value for ""APP_KEY" stopped this from working. Tried it with "TESTKEY vs TEST_KEY" and it had the same effect.
@AtifNaseem
@AtifNaseem 4 жыл бұрын
oooh!
@anicebitofbreadtomopupthel7144
@anicebitofbreadtomopupthel7144 3 жыл бұрын
Same problem for me, thank you for this.
@anicebitofbreadtomopupthel7144
@anicebitofbreadtomopupthel7144 3 жыл бұрын
For some reason it returns null, was wracking my brain on this for a good hour.
@mohanpatidar888
@mohanpatidar888 3 жыл бұрын
I gave without header function ($request->APP_KEY)it's working and with header function is not working ?
@AtifNaseem
@AtifNaseem 3 жыл бұрын
and any other changes?
@visual1996b
@visual1996b 4 жыл бұрын
Hi, Thank You Very Much . I want to ask you why in postman works perfectly and in curl not?
@AtifNaseem
@AtifNaseem 4 жыл бұрын
My pleasure. No problem, share curl errors. I use curl.
@visual1996b
@visual1996b 4 жыл бұрын
@@AtifNaseem When I write the URL in the postam the JSON result is showing, but when I use the same URL in chrome or curl it gives the error "App key not found "
@AtifNaseem
@AtifNaseem 4 жыл бұрын
in curl you can use other parameters using post. but in url you can't. If you share your CURL code with me. I will modify it according to error.
@yohanysturiz5257
@yohanysturiz5257 5 жыл бұрын
Que bien Muchas gracias!!, no entiendo mucho el ingles pero explicas muy bien!
@AtifNaseem
@AtifNaseem 5 жыл бұрын
gratias tibi
@mitalgal7467
@mitalgal7467 3 жыл бұрын
hie can you explain how to make update API in Lumen ?
@AtifNaseem
@AtifNaseem 3 жыл бұрын
here is great stuff auth0.com/blog/developing-restful-apis-with-lumen/
@amolacharya5342
@amolacharya5342 4 жыл бұрын
How is the middleware running? I mean, is it enough to be registered in kernel. Doesn't it need to be referenced in the route or the controller?
@AtifNaseem
@AtifNaseem 4 жыл бұрын
depends on you. How you manage your app.
@StefanoPartipilo
@StefanoPartipilo 3 жыл бұрын
Nice video. but if I want to pass the key to get the bees through vue is how can I do? I don't know how to get the key to be read via vue 😅
@AtifNaseem
@AtifNaseem 3 жыл бұрын
just like you did in postman
@vannhangang9079
@vannhangang9079 4 жыл бұрын
Thank for your video. But now in laravel 8, I can't go to 127.0.0.1:8000/dashboard, it show that "page not found". But in web.php, it have Route::get('/dashboard', function () { return view('dashboard'); })->middleware(['auth'])->name('dashboard'); Can you help me?
@AtifNaseem
@AtifNaseem 4 жыл бұрын
any other url working?
@Roots90s
@Roots90s 3 жыл бұрын
localhost is okay but when I host this api and access via postman return is "key not found" btw I'm using laravel 7
@AtifNaseem
@AtifNaseem 3 жыл бұрын
only error is key not found. Is everything else working?
@Roots90s
@Roots90s 3 жыл бұрын
@@AtifNaseem btw is working now thanks man.
@farhanfauzan8355
@farhanfauzan8355 4 жыл бұрын
hey man, im using laravel 6.*, why i dont get the APP_KEY that i set on postman's headers using $request->header('APP_KEY') ?? it returns an empty array.
@AtifNaseem
@AtifNaseem 4 жыл бұрын
I will soon update this series on Laravel 7.+
@farhanfauzan8355
@farhanfauzan8355 4 жыл бұрын
@@AtifNaseem yes please! Also, can you add tutorial about guzzle and curl ? That would be very nice..
@muhammadfikri9934
@muhammadfikri9934 4 жыл бұрын
hello this is a good tutorial, I managed to run on localhost but when I host this api and access via postman the message app key not found? did I make a mistake while hosting? thank you
@AtifNaseem
@AtifNaseem 4 жыл бұрын
You are right. I have pinned good solutions. Please read first 2 comments below the video.
@AldiJavier
@AldiJavier 3 жыл бұрын
auth key not found when hosting? whats a problem?
@AtifNaseem
@AtifNaseem 3 жыл бұрын
if is working properly on localhost then it should work on hosting.
@amitdev1485
@amitdev1485 4 жыл бұрын
iam using larave 5.6 but still i cant get $request->header('APP_KEY') in middleware on keeping APP_KEY at headers...
@AtifNaseem
@AtifNaseem 4 жыл бұрын
have you solved?
@amitdev1485
@amitdev1485 4 жыл бұрын
Yes just kept appkey it worked it seems _ is not working either app-key will work or simply appkey but not app_key
@M0stwan1eD
@M0stwan1eD 5 жыл бұрын
Thanks =3 Great tutorial!
@AtifNaseem
@AtifNaseem 5 жыл бұрын
My pleasure
@kalyanipriyadarsini
@kalyanipriyadarsini 4 жыл бұрын
Nice tutorial.. How to store the APP_KEY IN. env file and then compare it to get access the api
@AtifNaseem
@AtifNaseem 4 жыл бұрын
you can do in env XYZ_APP_KEY=[your_key_value] and use env('XYZ_APP_KEY','')
@kalyanipriyadarsini
@kalyanipriyadarsini 4 жыл бұрын
Thanks for quick response
@parisanaderi1647
@parisanaderi1647 3 жыл бұрын
it is not working to me. always return "app_key not found". ???????
@AtifNaseem
@AtifNaseem 3 жыл бұрын
can't say without looking at code.
@parisanaderi1647
@parisanaderi1647 3 жыл бұрын
@@AtifNaseem The problem is not the code. I realized the problem is copying and pasting the address in postman. I have to type the address postman every time. thankyou
@afaq96
@afaq96 4 жыл бұрын
Hello brother great series really helping me out but can you please tell about the best practices for maintaining Access Token and what technique to use in web laravel?
@AtifNaseem
@AtifNaseem 4 жыл бұрын
for Laravel best practices rest api, please check this www.lelocode.com/posts/laravel-api-tutorial-:-best-practices-laravel-rest-api-structure.
@gelhalim
@gelhalim 4 жыл бұрын
i faced this errur in login route : Method App\Http\Controllers\Auth\LoginController::showLoginForm does not exist.
@AtifNaseem
@AtifNaseem 4 жыл бұрын
does not exist, check the LoginController
@gelhalim
@gelhalim 4 жыл бұрын
@@AtifNaseem solved, its a comment generated automatically by unknown
@emmanuelochubili
@emmanuelochubili 3 жыл бұрын
How can I login into a system with a token generated by admin
@AtifNaseem
@AtifNaseem 3 жыл бұрын
token generated by admin and who is accessing?
@emmanuelochubili
@emmanuelochubili 3 жыл бұрын
@@AtifNaseem i want a user to login to a system without username or password but only a token generated by admin and sent to the user. Thanks
@geoffroyulrichkouadio3982
@geoffroyulrichkouadio3982 5 жыл бұрын
help me : Target class [App\Http\APP\Http\Middleware\AuthKey] does not exist.
@AtifNaseem
@AtifNaseem 5 жыл бұрын
is it showing anything else?
@justbrian8286
@justbrian8286 4 жыл бұрын
sir, despite using App-Key in camel case, I'm still getting the app key not found error
@AtifNaseem
@AtifNaseem 4 жыл бұрын
have you tested on postman?
@Askbowe
@Askbowe 4 жыл бұрын
@@AtifNaseem same error do i add the middlware like so ?? Route::middleware('Auth:Key')->get ............
@Askbowe
@Askbowe 4 жыл бұрын
GOT THE ERROR change API_KEY to API-KEY seems like the underscore is and issue
@itsrafsanjani
@itsrafsanjani 4 жыл бұрын
@@Askbowe You're right. Thanks for your help.
@sinatraforeign
@sinatraforeign 4 жыл бұрын
It's a good tutorial but why do we need country for? u should just stick at log-in tokens. Like server created random number and u have to input it in the Log-In. Just like authentication but without the user. only randomly generated password.
@AtifNaseem
@AtifNaseem 4 жыл бұрын
to create something different : )
@ДенисСопин-ж5п
@ДенисСопин-ж5п 4 жыл бұрын
Thank you so much! =)
@AtifNaseem
@AtifNaseem 4 жыл бұрын
You're welcome!
@thedriverux
@thedriverux 5 жыл бұрын
I don't get what I'm doing wrong. I have my key/value in postman exactly the same, yet my logic in AuthKey is returning "App key not found". why is Laravel not seeing the headers that Postman is sending?
@AtifNaseem
@AtifNaseem 5 жыл бұрын
Is your middleware working? coz we have this condition in middleware.
@thedriverux
@thedriverux 5 жыл бұрын
@@AtifNaseem the problem is that no matter what I set the condition to, it always gives me the error. For what ever the reason, it is not seeing the app_key in the header
@thedriverux
@thedriverux 5 жыл бұрын
ok, I fixed it by changing the line in AuthKey.php to this: $token = request()->header('App-Key'); It didn't like the Full Caps and needed the Camel Case with the dash instead of the underscore.
@AtifNaseem
@AtifNaseem 5 жыл бұрын
@@thedriverux Great
@oskarmaslek
@oskarmaslek 5 жыл бұрын
@@thedriverux I had the same problem, thanks for your help!
@zayyanramadhan9952
@zayyanramadhan9952 5 жыл бұрын
Hii can you help me? I learn your video, why must with artisan serve request header can be to get the header APP_KEY. But if i launch direct with laravel public without artisan serve, the header APP_KEY not have value at postman. So what i do for launch direct laravel public and get request header?
@AtifNaseem
@AtifNaseem 5 жыл бұрын
Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. The serve comamnd just starts up the php server. You can use localhost or 127.0.0.1
@zayyanramadhan9952
@zayyanramadhan9952 5 жыл бұрын
@@AtifNaseem i mean if with artisan serve i get port 8000 to launch, and this can get header request APP_KEY. But if i setting my website for hosting, i launch rest api like you in posman, header just null.
@zayyanramadhan9952
@zayyanramadhan9952 5 жыл бұрын
And have json message app key not found
@AtifNaseem
@AtifNaseem 5 жыл бұрын
@@zayyanramadhan9952Normally we test apis on local machine and then host it. Null header never occured. What is your host? Share your url I will check.
@AtifNaseem
@AtifNaseem 5 жыл бұрын
@Sergei Thank you. I was not understanding the point. You are right.
@meaningfullife7075
@meaningfullife7075 5 жыл бұрын
You sent the request from postman, I want to send it from CURL but i don't know how to add APP_KEY with the curl header !
@AtifNaseem
@AtifNaseem 5 жыл бұрын
$cURLConnection = curl_init(); curl_setopt($cURLConnection, CURLOPT_URL, 'xyz.com/api'); curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'APP-KEY: app-key-here' )); $data = curl_exec($cURLConnection); curl_close($cURLConnection); return json_decode($data);
@vishwakirtivardhan2691
@vishwakirtivardhan2691 4 жыл бұрын
Hi can you please help me!! How we can used passport with 2 different models, is it possible in laravel. I try to create an api Using another model in same project, but it was given me errors. Pls help me, waiting for reply. Video on this issue really helpful for most audience.
@AtifNaseem
@AtifNaseem 4 жыл бұрын
share your errors
@KistlakRajapakshaSevenNet
@KistlakRajapakshaSevenNet 5 жыл бұрын
Thank You Very Much Bro !! :D But, one thing.. I successfully created a token in one of the applications in cloud hosting. But, another app that is in the same cloud hosting returns true for JWT instead of a token. How can I Fix this ??
@AtifNaseem
@AtifNaseem 5 жыл бұрын
Thank you Kistalak Rajapaksha. Its difficult to say anything without looking at code :(
@haramohanmahalik2570
@haramohanmahalik2570 4 жыл бұрын
Hello your video asome. but how to create multi auth in laravel passport, actually I am a php developer,and I am also use guard API but not working
@AtifNaseem
@AtifNaseem 4 жыл бұрын
Will upload soon
@badbadi_krishika
@badbadi_krishika Жыл бұрын
Thank youu!
@AtifNaseem
@AtifNaseem Жыл бұрын
You're welcome!
@SorrowBee_2
@SorrowBee_2 3 жыл бұрын
why me can't make auth on laravel 8
@AtifNaseem
@AtifNaseem 3 жыл бұрын
Laravel 8 is slightly different, concept / code will remain same.
@mohdqayyoomkhan2446
@mohdqayyoomkhan2446 3 жыл бұрын
Thanks, 😊
@AtifNaseem
@AtifNaseem 3 жыл бұрын
You're welcome 😊
@asifmurtaz7625
@asifmurtaz7625 4 жыл бұрын
Salam Thanks for such an informative video. I was in search of solution to a schnario when I happened to came across this video. can you please inform if this information can resolve my issue? I have developed a web based hospital management system. Users log in and larvel authenticate using the default Auth scaffold. Now we want an android based app to function upon the existing logic. How the app user can be authenticated?
@AtifNaseem
@AtifNaseem 4 жыл бұрын
You can use your default auth and on successful login can save csrf token to your android app for post submissions.
@HiMu2324
@HiMu2324 4 жыл бұрын
You deleted the learning table with all countries data,how come you are fetching it afterwards? learning table does not exist anymore!!!!
@AtifNaseem
@AtifNaseem 4 жыл бұрын
1:57 when you run php artisan migrate it actually creates all the tables and data.
@HiMu2324
@HiMu2324 4 жыл бұрын
@@AtifNaseem so the tables now exist locally on the machine not in php my admin sql database?
@amitdev1485
@amitdev1485 4 жыл бұрын
i guess APPKEY will work instead of APP_KEY...
@AtifNaseem
@AtifNaseem 4 жыл бұрын
yes amit dev
@developer_nijat
@developer_nijat 4 жыл бұрын
This method is not good. Because you can access api route via api/country? App_key=abcdf
@developer_nijat
@developer_nijat 4 жыл бұрын
Maybe question how to find app key. From network headers
@AtifNaseem
@AtifNaseem 4 жыл бұрын
actually these types of apis are accessed using server side programming.
@swarnadeeppramanick
@swarnadeeppramanick 4 жыл бұрын
Thanks a lot
@AtifNaseem
@AtifNaseem 4 жыл бұрын
Most welcome
@mahabub0306
@mahabub0306 5 жыл бұрын
Bhai, Laravel 6 auth with jwt and Postman....plzzzz
@AtifNaseem
@AtifNaseem 5 жыл бұрын
starting soon Laravel 6
@umayantharavindu3703
@umayantharavindu3703 2 жыл бұрын
hi, i watched your video, it was really helpful. can Str::random created token pass from controller into middleware instead of ABCDEFGH.....
@AtifNaseem
@AtifNaseem 2 жыл бұрын
Thanks umayantha ravindu. Yes, you can
@hamzashan8349
@hamzashan8349 5 жыл бұрын
sir how to store jwt token
@AtifNaseem
@AtifNaseem 5 жыл бұрын
for cache watch this kzbin.info/www/bejne/q3rEqquAo8hqitE
@louisaldorio7251
@louisaldorio7251 4 жыл бұрын
I cant make uath
@AtifNaseem
@AtifNaseem 4 жыл бұрын
execute these composer require laravel/ui php artisan ui vue --auth
@vantienvlog9870
@vantienvlog9870 5 жыл бұрын
video thật ý nghĩa
@AtifNaseem
@AtifNaseem 5 жыл бұрын
Cảm ơn bạn.
@MuhammadAdnan-gx6rd
@MuhammadAdnan-gx6rd 5 жыл бұрын
Bhai Ecommerce with Laravel please. ..... thanks ...
@AtifNaseem
@AtifNaseem 5 жыл бұрын
Sure. Now I am starting ecommerce series soon. Don't forget to like : )
@MuhammadAdnan-gx6rd
@MuhammadAdnan-gx6rd 5 жыл бұрын
@@AtifNaseem subd + like
@muhammedrasituyank99
@muhammedrasituyank99 3 жыл бұрын
aleyküm selam bro thanks
@AtifNaseem
@AtifNaseem 3 жыл бұрын
Walaikum Assalam. Welcome.
@dougtktube
@dougtktube 5 жыл бұрын
thx
@AtifNaseem
@AtifNaseem 5 жыл бұрын
My pleasure.
@mohammadalabd189
@mohammadalabd189 5 жыл бұрын
Finally
@AtifNaseem
@AtifNaseem 5 жыл бұрын
Thank you.
@SalvadorRap
@SalvadorRap 4 жыл бұрын
Giving app key in headers is stupid method. Everyone can see that key
@AtifNaseem
@AtifNaseem 4 жыл бұрын
it is starting point...
@jorgeleon9212
@jorgeleon9212 4 жыл бұрын
si jala crack
@AtifNaseem
@AtifNaseem 4 жыл бұрын
yes
@SHAJ.T3CH
@SHAJ.T3CH 5 жыл бұрын
@AtifNaseem
@AtifNaseem 5 жыл бұрын
Thank you. Don't forget to like : )
@MsHorbjorn
@MsHorbjorn 4 жыл бұрын
Wtf ?!
@AtifNaseem
@AtifNaseem 4 жыл бұрын
Watch again.
@seyedaliroshan2386
@seyedaliroshan2386 5 жыл бұрын
علیکم السلام
@AtifNaseem
@AtifNaseem 5 жыл бұрын
: )
Resource - RESTful API with Laravel - 06
7:18
Atif Naseem
Рет қаралды 20 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Securing a Laravel API in 20 minutes with JWTs
20:36
Andrew Schmelyun
Рет қаралды 79 М.
Difference between cookies, session and tokens
11:53
Valentin Despa
Рет қаралды 673 М.
Laravel 8 tutorial -  API authentication with Sanctum
15:51
Code Step By Step
Рет қаралды 82 М.
Complete Api Authentication with Laravel Passport
14:57
WebDevMatics
Рет қаралды 83 М.
Laravel 8 REST API With Sanctum Authentication
54:13
Traversy Media
Рет қаралды 552 М.