PHP code example of maksimovic / slim-oauth2-middleware
1. Go to this page and download the library: Download maksimovic/slim-oauth2-middleware 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/ */
maksimovic / slim-oauth2-middleware example snippets
use Chadicus\Slim\OAuth2\Middleware\Authorization;
use OAuth2;
use OAuth2\Storage;
use OAuth2\GrantType;
$storage = new Storage\Memory([
'client_credentials' => [
'administrator' => ['client_id' => 'administrator', 'client_secret' => 'password', 'scope' => 'superUser'],
],
]);
$server = new OAuth2\Server(
$storage,
['access_lifetime' => 3600],
[new GrantType\ClientCredentials($storage)]
);
$auth = new Authorization($server, $container);
// Slim 4
$app->get('/foos', $handler)->add($auth);
$app->post('/foos', $handler)->add($auth->withRequiredScope(['superUser']));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.