1. Go to this page and download the library: Download zfr/zfr-oauth2-server 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/ */
zfr / zfr-oauth2-server example snippets
$authTokenService = new TokenService($objectManager, $authTokenRepository, $scopeRepository);
$accessTokenService = new TokenService($objectManager, $accessTokenRepository, $scopeRepository);
$refreshTokenService = new TokenService($objectManager, $refreshTokenRepository, $scopeRepository);
$authorizationGrant = new AuthorizationGrant($authTokenService, $accessTokenService, $refreshTokenService);
$authorizationServer = new AuthorizationServer([$authorizationGrant]);
// Response contains the various parameters you can return
$response = $authorizationServer->handleRequest($request);
$user = new User(); // must implement TokenOwnerInterface
// ...
$response = $authorizationServer->handleRequest($request, $user);
$accessTokenService = new TokenService($objectManager, $accessTokenRepository, $scopeRepository);
$resourceServer = new ResourceServer($accessTokenService);
if (!$token = $resourceServer->getAccessToken($request, ['write']) {
// there is either no access token, or the access token is expired, or the access token does not have
// the `write` scope
}