Lumen Authentication: unknown index: provider

I'm using Lumen for the first time and trying to setup token authentication. After following all of the instructions in the lumen documentation, I'm getting the following error when trying to access a page;

ErrorException in AuthManager.php line 152:
Undefined index: provider
in AuthManager.php line 152
at Application->Laravel\Lumen\Concerns\{closure}('8', 'Undefined index: provider', '/home/webdev/public_html/project/vendor/illuminate/auth/AuthManager.php', '152', array('name' => 'api', 'config' => array('driver' => 'token'))) in AuthManager.php line 152
at AuthManager->createTokenDriver('api', array('driver' => 'token')) in AuthManager.php line 92
at AuthManager->resolve('api') in AuthManager.php line 70
at AuthManager->guard(null) in Authenticate.php line 38
at Authenticate->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in RoutesRequests.php line 621
at Application->sendThroughPipeline(array('App\Http\Middleware\Authenticate'), object(Closure)) in RoutesRequests.php line 382
at Application->dispatch(object(Request)) in RoutesRequests.php line 327
at Application->run(object(Request)) in index.php line 31

Open in new window

The steps I've taken are;

Uncommented the following in 'bootstrap/app.php'

Open in new window

Also added this line to 'bootstrap/app.php'

Open in new window

I've setup the database connection details in '/env', and I've created a user table which contains an 'api_token' field. Here's the User model;

namespace App;

use Illuminate\Auth\Authenticatable;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;

 * @property int $id
 * @property bool $active
 * @property string $api_token
 * @property string $full_name
 * @property string $email
 * @property string $username
 * @property string $password
 * @property string $avatar
 * @property string $background
 * @property string $date_last_login
 * @property string $facebook_id
 * @property string $facebook_token
 * @property string $twitter_id
 * @property string $twitter_token
class User extends Model implements AuthenticatableContract, AuthorizableContract
    use Authenticatable, Authorizable;

     * The attributes that are mass assignable.
     * @var array
    protected $fillable = [
        'full_name', 'email',

     * The attributes excluded from the model's JSON form.
     * @var array
    protected $hidden = [

Open in new window

I have made no changes to the Authentication Middleware, and the AuthServiceProvider also remains exactly the same with no changes.

I've done my best to trace through the lumen code to see where 'provider' is supposed to be set, but I can't seem to find where the issue is.

Can anyone help?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SheppardDigitalAuthor Commented:
As a further pointer, I found in /config/auth.php the following reference to setting up a provider;

return [
    'defaults' => [
        'guard' => env('AUTH_GUARD', 'api'),
    'guards' => [
        'api' => ['driver' => 'token'],
    'providers' => [
    'passwords' => [

Open in new window

It seems at least that I need to setup the configuration to setup 'eloquent' as a provider for auth, however I can't find any documentation that tells me how to do this in the configuration file?
SheppardDigitalAuthor Commented:
I seem to have resolved this by tracing through the code to determine what lumen was expecting.

I copied the /vendor/laravel/config/ folder to the root of my project, deleted all .php files in the new folder except the auth.php file.

I changed the guards section of the file to;

'guards' => [
        'api' => ['driver' => 'token', 'provider' => 'api'],

Open in new window

and the providers section to;

'providers' => [
        'api' => ['driver' => 'eloquent', 'model' => 'App\User'],

Open in new window

This seems to resolve the issue. It's a shame this doesn't just work out of the box and that the documentation doesn't seem to tell you that you need to do something like this.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SheppardDigitalAuthor Commented:
Resolved myself
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.