AccessTokenRepository.php in Simple OAuth (OAuth2) & OpenID Connect 5.x
File
src/Repositories/AccessTokenRepository.php
View source
<?php
namespace Drupal\simple_oauth\Repositories;
use Drupal\simple_oauth\Entities\AccessTokenEntity;
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
class AccessTokenRepository implements AccessTokenRepositoryInterface {
use RevocableTokenRepositoryTrait;
protected static $bundleId = 'access_token';
protected static $entityClass = 'Drupal\\simple_oauth\\Entities\\AccessTokenEntity';
protected static $entityInterface = 'League\\OAuth2\\Server\\Entities\\AccessTokenEntityInterface';
public function persistNewAccessToken(AccessTokenEntityInterface $access_token_entity) {
$this
->persistNew($access_token_entity);
}
public function revokeAccessToken($token_id) {
$this
->revoke($token_id);
}
public function isAccessTokenRevoked($token_id) {
return $this
->isRevoked($token_id);
}
public function getNewToken(ClientEntityInterface $client_entity, array $scopes, $user_identifier = NULL) {
$access_token = new AccessTokenEntity();
$access_token
->setClient($client_entity);
foreach ($scopes as $scope) {
$access_token
->addScope($scope);
}
$access_token
->setUserIdentifier($user_identifier);
return $access_token;
}
}