Search code examples
laravelapilaravel-passportlaravel-middleware

Laravel passport allow API access for guest


hello in Laravel I have implemented passport authentication and I need to allow some of my routes for unauthenticated users. I have got this answer from stack overflow and but it shows the following error Declaration of App\Http\Middleware\Authenticate::authenticate(array $guards) must be compatible with Illuminate\Auth\Middleware\Authenticate::authenticate($request, array $guards)


Solution

  • Your Authenticate class was declaration, change your class to

    public static function authenticate($request, array $guards)
    

    not

    public static function authenticate(array $guards)
    

    $request

    is required.