Category: Laravel, PHP, MySQL, api

The Laravel framework gives us a lot of things out of the box. When coding an API, you should be able to authenticate users (finding out who the user is), authorize users (allowing a user to only access specific routes based on some privileges. In this short tutorial, I am going to show how you can provide authentication for your API in Laravel.

Some of the ways are: Laravel Authentication (Laravel’s built in Authentication) Laravel guards: using a JWT library (We shall be using this in the tutorial) Laravel Socialite Laravel Passport Laravel Sanctum

Note: This is a basic implementation, in real life applications, you can check if user records exist in the database first before they are allowed to attempt login.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners