Jwt-auth: Auth guard driver [api] is not defined.

Created on 10 Apr 2016  路  3Comments  路  Source: tymondesigns/jwt-auth

Hi. Greate package. Thanks for hard work

I got this error when try to use it with Lumen:

in AuthManager.php line 97
at AuthManager->resolve('api') in AuthManager.php line 70
at AuthManager->guard() in AuthManager.php line 288
at AuthManager->__call('once', array(array('email' => '[email protected]', 'password' => 'hehehe'))) in IlluminateAuthAdapter.php line 39
at AuthManager->once(array('email' => '[email protected]', 'password' => 'hehehe')) in IlluminateAuthAdapter.php line 39
at IlluminateAuthAdapter->byCredentials(array('email' => '[email protected]', 'password' => 'hehehe')) in JWTAuth.php line 108
at JWTAuth->attempt(array('email' => '[email protected]', 'password' => 'hehehe')) in Facade.php line 218
at Facade::__callStatic('attempt', array(array('email' => '[email protected]', 'password' => 'hehehe'))) in AuthController.php line 43
at JWTAuth::attempt(array('email' => '[email protected]', 'password' => 'hehehe')) in AuthController.php line 43
at AuthController->postLogin(object(Request))
at call_user_func_array(array(object(AuthController), 'postLogin'), array(object(Request))) in Container.php line 507
at Container->call(array(object(AuthController), 'postLogin'), array()) in RoutesRequests.php line 586
at Application->callControllerCallable(array(object(AuthController), 'postLogin'), array()) in RoutesRequests.php line 553
at Application->callLumenController(object(AuthController), 'postLogin', array(true, array('uses' => 'App\Http\Controllers\AuthController@postLogin'), array())) in RoutesRequests.php line 526
at Application->callControllerAction(array(true, array('uses' => 'App\Http\Controllers\AuthController@postLogin'), array())) in RoutesRequests.php line 494
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\Http\Controllers\AuthController@postLogin'), array())) in RoutesRequests.php line 479
at Application->handleFoundRoute(array(true, array('uses' => 'App\Http\Controllers\AuthController@postLogin'), array())) in RoutesRequests.php line 376
at Application->Laravel\Lumen\Concerns\{closure}() in RoutesRequests.php line 629
at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 382
at Application->dispatch(null) in RoutesRequests.php line 327
at Application->run() in index.php line 28

I followed this link: https://github.com/dingo/api/issues/958
Create new auth.php config file:

'defaults' => [
        'guard' => 'api',
        'passwords' => 'users',
    ],

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

        'api' => [
            'driver' => 'jwt',
            'provider' => 'users',
        ],
    ]

After debugging i found that there is no driver for jwt.

And in AuthManager class only support 2 driver: session and token.

I tried to use both of them in the auth.php config file. But none of them work.

Do you have any idea how to fix this isse?

Most helpful comment

Hey it seems that you followed this tutorial. I also had troubles with this and had the same issues. I started from zero and found #564

At the end of #564 you can find some gist either with or without using dingo. The one without dingo worked perfectly for me.

All 3 comments

Hey it seems that you followed this tutorial. I also had troubles with this and had the same issues. I started from zero and found #564

At the end of #564 you can find some gist either with or without using dingo. The one without dingo worked perfectly for me.

@JPeer264 thanks a lot.

did you solve it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NaelsonBrasil picture NaelsonBrasil  路  3Comments

functionpointdaniel picture functionpointdaniel  路  3Comments

gamelife1314 picture gamelife1314  路  3Comments

kofi1995 picture kofi1995  路  3Comments

shah-newaz picture shah-newaz  路  3Comments