Open jelkevdh opened 8 years ago
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?
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:
0 /var/www/api/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(133): Symfony\Component\Debug\Exception\FatalErrorException->__construct()
1 /var/www/api/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(118): Illuminate\Foundation\Bootstrap\HandleExceptions->fatalExceptionFromError()
2 /var/www/api/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(0): Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
3 /var/www/api/vendor/tymon/jwt-auth/src/Providers/Auth/IlluminateAuthAdapter.php(39): Illuminate\Auth\AuthManager->__call()
4 /var/www/api/vendor/tymon/jwt-auth/src/Providers/Auth/IlluminateAuthAdapter.php(39): Illuminate\Auth\AuthManager->once()
5 /var/www/api/vendor/tymon/jwt-auth/src/JWTAuth.php(108): Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter->byCredentials()
6 /var/www/api/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(238): Tymon\JWTAuth\JWTAuth->attempt()
7 /var/www/api/app/Http/Controllers/Auth/LoginController.php(83): Illuminate\Support\Facades\Facade::__callStatic()
8 /var/www/api/app/Http/Controllers/Auth/LoginController.php(83): Tymon\JWTAuth\Facades\JWTAuth::attempt()
`