Courses

How to Build Laravel 11 API From Scratch

Authentication with Laravel Passport and Password Grant Type

Summary of this lesson:
- Setting up Laravel Passport
- OAuth2 implementation
- Token expiration and refresh mechanics
- Password grant authentication flow

This lesson will cover API authentication using the Laravel Passport package. If you look at the Passport documentation, it is huge, and for someone new to API authentication, it would be hard to understand and use.

We have covered Sanctum, which I recommend using, so we will check the basics of Passport in this lesson.


You must understand that Passport is a server based on the OAuth2 standard. This standard isn't from Laravel or PHP. It's a general web standard for authentication applications.

The Laravel Passport is based on the PHP OAuth 2.0 Server. But that server follows the OAuth specification. You would need to learn these things if you wanted to look deeper into how OAuth works and how to use it elsewhere.


You can install Laravel passport using an artisan command install:api and passing --passport as an option.

php artisan install:api --passport
php artisan migrate

Next, you need to configure your application...

The full lesson is only for Premium Members.
Want to access all 23 lessons of this course? (58 min read)

You also get:

  • 69 courses (majority in latest Laravel 11)
  • Premium tutorials
  • Access to repositories
  • Private Discord