How to fix auth guard api is not defined laravel 8

The issue, auth guard api is not defined starts showing up in laravel 5, 6, 7, 8 and 9. To fix this issue all we need to edit config/auth.php file. All we need to add api section into config/auth.php file.

  • Open config/auth.php
  • Clear config and cache

Path: config/auth.php

lets open config/auth.php file and add following code the guards section

  'api' => [
        'driver' => 'token',
        'provider' => 'users',
    ],

Flush Config/Cache

Now after making above changes, let clear laravel configuration and cache so we can see the changes taking effects on laravel application.

php artisan config:clear

Leave a Comment