tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.23k stars 1.55k forks source link

Auth guard driver [api] is not defined. #843

Open deepu9 opened 7 years ago

deepu9 commented 7 years ago

Hi, I've installed Laravel 5.3 with Dingo & JWT Auth modules. I've configured both the modules according to their wiki documentation, but I'm still getting the error "Auth guard driver [api] is not defined.", when I try to login into the app. Please find my configs below:

config/auth.php

'defaults' => [
        'guard' => 'api',
        'passwords' => 'users',
    ],
'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'api' => [
            'driver' => 'jwt',
            'provider' => 'users',
        ],
    ],

routes/api.php

$api = app('Dingo\Api\Routing\Router');

/**
 * User Details
 */
$api->version('v1', function ($api) {

    //User Routes
    $api->group(['middleware' => ['api', 'cors'], 'prefix' => 'user'], function($api) {
        //User Login
        $api->post('login', 'App\Http\Controllers\Auth\LoginController@login');

        //User Register
        $api->post('register', 'App\Http\Controllers\Auth\RegisterController@create');

//      $api->group(['middleware' => 'jwt.auth'], function($api) {
//      });
    });
});

Can anyone help me out.

lukevear commented 7 years ago

@deepu9 I had the same issue with Laravel 5.3 that you are experiencing. This little package I put together might help you out.

wilcarjose commented 7 years ago

@lukevear I installed you package, any idea about this error: "Call to undefined method LukeVear\JWTAuthGuard\AuthGuard::once()"

lukevear commented 7 years ago

@wilcarjose Looks like I didn't implement the once method in the guard. If you'd like to do it, feel free to send a pull request, or I can do it over the weekend.

Also, as @tymondesigns pointed out, the alpha version of this package do have an auth guard, my package will only work with 0.5.*.

deepu9 commented 7 years ago

Thanks to all for helping me out.

antonioreyna commented 4 years ago

did you solve it?

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.