bump, same issue here on a brand new project (Laravel 5.5, passport 4.0)
Sep 11, 2017
8
Level 1
Method attempt does not exist or Auth guard driver [api] is not defined.
I use Lumen 5, and I'm having trouble with using authentication.
I have uncommented
$app->register(App\Providers\AuthServiceProvider::class);
$app->withFacades();
$app->withEloquent();
in app.php but authentication not work /
public function postLogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required',
]);
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials, $request->has('remember'))) {
return ['result' => 'ok'];
}
return ['result' => 'not ok'];
}
If I create a request to /login with params need to succesful request, display error:
Method attempt does not exist.
Ok, next I create new auth.php config
<?php
return [
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
'guards' => [
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => \App\User::class
]
]
];
and display next error: Auth guard driver [api] is not defined.
Why? The api guard is defined in the config?!
Thanks for replay!
Please or to participate in this conversation.