Laravel API Authentication: Protecting Routes

Via Middleware

Route::get('/user', function () {
    //
})->middleware('auth:api');

Passing The Access Token

$response = $client->request('GET', '/api/user', [
    'headers' => [
        'Accept' => 'application/json',
        'Authorization' => 'Bearer '.$accessToken,
    ],
]);

Laravel API Authentication: Protecting Routes — Structure map

Clickable & Draggable!

Laravel API Authentication: Protecting Routes — Related pages: