Search code examples
phplaravellumenlumen-5.2

Lumen Authentication


Just can't get the Lumen authentication to work at all.

I have a fresh install and trying to follow the docs here:

https://lumen.laravel.com/docs/5.2/authentication

I've Uncommented the AuthProvider line in the app.php file (along with everything else, facade, etc). Then in a simple controller I just do dd(Auth::use()).

I just can't get around this error:

Undefined index: provider
in AuthManager.php line 152
at Application->Laravel\Lumen\Concerns\{closure}('8', 'Undefined index: provider', '/home/vagrant/Code/gryd/api.gryd.com/vendor/illuminate/auth/AuthManager.php', '152', array('name' => 'api', 'config' => array('driver' => 'token'))) in AuthManager.php line 152

Any ideas?

EDIT:

Since someone asked for a code sample.

  1. Install Lumen
  2. Uncomment everything in app.php
  3. Put this in routes:

    $app->get('/api/v1/users/{id}', function () { dd(\Auth::user()); });


Solution

  • Well I still haven't found out how to change the api request type via .env. But for now switching it to token seems to work.

    Changed Auth::viaRequest('api', functi to Auth::viaRequest('token', funct.