Add custom middleware to Laravel Passport endpoints

You can try this: Go to app/Providers/AuthServiceProvider and look for the function boot(). In this function you will see a line for registering routes for Passport. The default code is Passport::routes(). This routes() method accepts an options array as second argument. You can use it to set middlewares for Passport routes.

Passport::routes(null, ['middleware' => 'api']);

In the app/Providers/AuthServiceProvider include the Route facade by adding this use statement somewhere in the top:

use Illuminate\Support\Facades\Route;

Then on the boot() method, put the Passport::routes() inside a Route::group() like this:

Route::group(['middleware'=>'MyFunkyCustomMiddleware'], function(){
    Passport::routes(); // <-- Replace this with your own version
});

Hope that helps!