1. Go to this page and download the library: Download krak/doctrine-oauth2 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
krak / doctrine-oauth2 example snippets
$app = new Laravel\Lumen\Application(__DIR__ . '/..');
$app->register(LaravelDoctrine\ORM\DoctrineServiceProvider::class);
$app->register(LaravelDoctrine\Migrations\MigrationsServiceProvider::class);
$app->register(Krak\DoctrineOAuth2\OAuth2ServiceProvider::class);
$app['oauth2.seeds']->push(function($em, $logger) {
$scopes = [
new Scope('basic', 'Basic', 'Allows basic access to the API.'),
new Scope('user', 'User', 'Allows user access to the API.'),
];
$logger->info("Creating local client");
$client = new Client('local', 'local', 'local123', '', $scopes);
$em->persist($client);
foreach ($scopes as $scope) {
$logger->info("Creating scope: ". json_encode($scope, JSON_PRETTY_PRINT));
$em->persist($scope);
}
});
$app->router->group(['middleware' => 'oauth2'], function($router) {
$router->get('/', function(Illuminate\Http\Request $req) {
return $req->attributes->all();
});
});