Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alirezaevil81's avatar

laravel passport guard error

{ "php": "^8.1", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^10.10", "laravel/passport": "^12.3", "laravel/sanctum": "^3.3", "laravel/tinker": "^2.8" }

this is my compor

config/auth.php:

'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'passport', 'provider' => 'users', ], ]

config/passport.php:

'guard' => 'api'

when request to route oauth/authorize on get method I got this error:

TypeError: Laravel\Passport\Http\Controllers\AuthorizationController::__construct(): Argument #2 ($guard) must be of type Illuminate\Contracts\Auth\StatefulGuard, Laravel\Passport\Guards\TokenGuard given in file C:\PHP\rest-api-backend\vendor\laravel\passport\src\Http\Controllers\AuthorizationController.php on line 52

0 likes
1 reply
experimentor's avatar

@alirezaevil81 Please post the code from your AuthorizationController. Looks like you are using the wrong Guard class.

please use markdown formatting to post the code. Otherwise it will be very difficult to understand.

Please or to participate in this conversation.