Composer is the recommended way to install this package. Add the following line to your composer.json file:
"lucadegasperi/oauth2-server-laravel": "^5.0"
Then run composer update to get the package.
In your bootstrap/app.php
register service providers
$app->register(\LucaDegasperi\OAuth2Server\Storage\FluentStorageServiceProvider::class);
$app->register(\LucaDegasperi\OAuth2Server\OAuth2ServerServiceProvider::class);
... and middleware
$app->middleware([
\LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware::class
]);
... and route middleware
$app->routeMiddleware([
'check-authorization-params' => \LucaDegasperi\OAuth2Server\Middleware\CheckAuthCodeRequestMiddleware::class,
'csrf' => \Laravel\Lumen\Http\Middleware\VerifyCsrfToken::class,
'oauth' => \LucaDegasperi\OAuth2Server\Middleware\OAuthMiddleware::class,
'oauth-client' => \LucaDegasperi\OAuth2Server\Middleware\OAuthClientOwnerMiddleware::class,
'oauth-user' => \LucaDegasperi\OAuth2Server\Middleware\OAuthUserOwnerMiddleware::class,
]);
Copy vendor/lucadegasperi/oauth2-server-laravel/config/oauth2.php
to your own config folder (config/oauth2.php
in your project root). It has to be the correct config folder as it is registered using $app->configure()
.
First copy the migrations from vendor/lucadegasperi/oauth2-server-laravel/database/migrations
to your applications database/migrations
directory.
Uncomment $app->withEloquent();
and run php artisan migrate
.
If you get an error saying the Config class can not be found, add class_alias('Illuminate\Support\Facades\Config', 'Config');
to your bootstrap/app.php
file and uncomment $app->withFacades();
temporarily to import the migrations.