jwt-auth
jwt-auth copied to clipboard
cant install on lumen 6
hi I get an error when installing on lumen 6
Your environment
Q | A |
---|---|
Bug? | no / yes |
New Feature? | no / yes |
Framework | Lumen |
Framework version | 6 |
Package version | 0.5.12 |
PHP version | 7.x.y |
Problem 1 - Installation request for tymon/jwt-auth ^0.5.12 -> satisfiable by tymon/jwt-auth[0.5.12]. - Conclusion: remove illuminate/contracts v6.13.1 - Conclusion: don't install illuminate/contracts v6.13.1
Try this:
composer require tymon/jwt-auth:1.0.0-rc.5.1
Support for Laravel 6 was added on 1.0.0-rc.5
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.
My difficulty is being in the installation in lumen 8 Some adaptation in the tutorial to make it work
I get the error: Target class [api] does not exist.
My difficulty is being in the installation in lumen 8 Some adaptation in the tutorial to make it work
I get the error: Target class [api] does not exist.
there's a mistake in documentation , in lumen there's no middleware named api , the right middleware that registered in bootstrap/app.php is
$app->routeMiddleware([ 'auth' => App\Http\Middleware\Authenticate::class, ]);
wrong code in documentation
Route::group([
here --> 'middleware' => 'api',
'prefix' => 'auth'
], function ($router) {
Route::post('login', 'AuthController@login');
Route::post('logout', 'AuthController@logout');
Route::post('refresh', 'AuthController@refresh');
Route::post('me', 'AuthController@me');
});
change the middleware to 'auth' and move login route out of route group so yo can access it without token
the right code
Route::post('api/login', 'AuthController@login');
Route::group([
'middleware' => 'auth',
'prefix' => 'api'
], function ($router) {
Route::post('logout', 'AuthController@logout');
Route::post('refresh', 'AuthController@refresh');
Route::post('me', 'AuthController@me');
});
curl 127.0.0.1:8000/api/login --data "[email protected]&password=123"
{"access_token":"eyJ0e...","token_type":"bearer","expires_in":3600}
curl 127.0.0.1:8000/api/me -H "Authorization: Bearer eyJ0e..." -X POST
{"id":1,"name":"admin","email":"[email protected]","email_verified_at":null,"remember_token":null,"created_at":"2021-12-30T19:11:42.000000Z","updated_at":"2021-12-30T19:11:42.000000Z","permissions":""}