You are here

public function AccessTokenRepository::getNewToken in Simple OAuth (OAuth2) & OpenID Connect 5.x

Same name and namespace in other branches
  1. 8.4 src/Repositories/AccessTokenRepository.php \Drupal\simple_oauth\Repositories\AccessTokenRepository::getNewToken()
  2. 8.2 src/Repositories/AccessTokenRepository.php \Drupal\simple_oauth\Repositories\AccessTokenRepository::getNewToken()
  3. 8.3 src/Repositories/AccessTokenRepository.php \Drupal\simple_oauth\Repositories\AccessTokenRepository::getNewToken()

File

src/Repositories/AccessTokenRepository.php, line 62

Class

AccessTokenRepository
The access token repository.

Namespace

Drupal\simple_oauth\Repositories

Code

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;
}