Hi,
Since I upgraded to laravel 5.3 I get a FatalErrorException using this package. Is this a known issue?
It's using the TokenGuard and that class does not have the once method (see below)
Thanks,
J. van der Horst
`[2016-08-31 21:42:59] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined method Illuminate\Auth\TokenGuard::once()' in /var/www/api/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php:294
Stack trace:
`
Hello @jelkevdh
I think your problem is due to the _default authentication "guard"_
Check config/auth.php.
'defaults' => [
'guard' => 'web',
'passwords' => 'users'
],
Hello @jelkevdh,
You may be having the following configuration:
'defaults' => [
'guard' => 'api',
'passwords' => 'users'
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
]
],
then, you will get the above error.
@deepu9 so what should the configuration above look like? I'm having exactly the same issue. My web guard is the one used overall to do session authentication, then I have my API, which I want to authenticate using the api guard.
For this Jwt-auth package to work, are we saying the guard it will be using must have been specified as the default?
Sorry @gthuo, I'm not sure about the config, but from what I remember is that when you assign "api" as a default guard, then it will look for those drivers, if it couldn't find any of them, then it will throw error.
Any luck guys I am having same issue.
If I change api guard driver to jwt-auth or token I get following errors respectively:
Auth guard driver [api] is not defined.
Call to undefined method Illuminate\Auth\TokenGuard::attempt()
But its working fine with session driver i.e.
'api' => [
'driver' => 'session',
'provider' => 'app_users',
],
What token should I use for api guard?
I have this issue as well
I have a same error too.
@imranali1 Is this worked fine??
'api' => [ 'driver' => 'session', 'provider' => 'app_users', ],
I couldn't authenticate by setting driver to session.
@bmf-san
Yes, it worked for me as a work around, but actually you should be using 1.0+ version of jwt-auth to authenticate using guards.
Check this thread.
https://github.com/tymondesigns/jwt-auth/issues/1029
Thanks.
thanks i changed 'guard' => 'api', to 'guard' => 'web', and it worked
User attempt() instead of check .. It's work for me.
if (Auth::check(['email' => $email, 'password' => $password,false, false])) {
$user = Auth::user();
$data = array(
"is_login" => true,
"name" => $user->name,
"api_token" => $user->api_token
);
return Response::json(
array(
'status' => true,
'data' => $data,
'msg' => "Login Successfully"
), 200
);
}
Hey @jelkevdh you need to update your config/auth.php file to look like this
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'jwt',
'provider' => 'users',
],
],
Remember to change the api driver from token to jwt.
I have the same issue.
My api driver is set to jwt and my default guard is set to web.
I don't want to change my default guard.
Has anyone found a solution on this?
Most helpful comment
I have this issue as well