JWT Auth API

JSON Web Token Authentication for your OctoberCMS API integrated with RainLab.User

Back to JWT Auth API Support

gionatan18523
gionatan18523

I just stumbled upon on this error which seems too big to be true :-) On a fresh install of october on docker I installed the Rainlab User plugin and this plugin but as I try the /api/login route (with POST method) I get this error:

InvalidArgumentException: Auth guard [] is not defined. in /var/www/html/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php:84
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php(68): Illuminate\Auth\AuthManager->resolve(NULL)
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php(292): Illuminate\Auth\AuthManager->guard()
#2 /var/www/html/plugins/vdomah/jwtauth/vendor/tymon/jwt-auth/src/Providers/Auth/IlluminateAuthAdapter.php(39): Illuminate\Auth\AuthManager->__call('once', Array)
#3 /var/www/html/plugins/vdomah/jwtauth/vendor/tymon/jwt-auth/src/JWTAuth.php(108): Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter->byCredentials(Array)
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Tymon\JWTAuth\JWTAuth->attempt(Array)
#5 /var/www/html/plugins/vdomah/jwtauth/routes.php(18): Illuminate\Support\Facades\Facade::__callStatic('attempt', Array)
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(198): System\Classes\PluginManager->{closure}(Object(Illuminate\Support\Facades\Request))
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(172): Illuminate\Routing\Route->runCallable()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\Routing\Route->run()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#14 /var/www/html/vendor/october/rain/src/Router/CoreRouter.php(20): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): October\Rain\Router\CoreRouter->dispatch(Object(Illuminate\Http\Request))
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#18 /var/www/html/vendor/october/rain/src/Foundation/Http/Middleware/CheckForMaintenanceMode.php(25): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): October\Rain\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#24 /var/www/html/index.php(43): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#25 {main}  

Did anyone ever meet this error?

Last updated

snakemaster
snakemaster

I just had the same error. It appears if the config/auth.php in the OctoberCMS installation is present, the default plugin config/auth.php is ignored. Once I copied the contents to my installation config/auth.php, the login worked.

As you can notice guard[] is empty where it should be guard[web] or whatever your default is. This meant the default guard was not defined at all.

I don't know if this is a bug or expected behaviour. In my opinion the plugin configs should extend the entries that are not set in the project config.

1-2 of 2