You are here

public function KnownClientsRepository::rememberClient in Simple OAuth (OAuth2) & OpenID Connect 8.4

Same name and namespace in other branches
  1. 8.3 src/KnownClientsRepository.php \Drupal\simple_oauth\KnownClientsRepository::rememberClient()
  2. 5.x src/KnownClientsRepository.php \Drupal\simple_oauth\KnownClientsRepository::rememberClient()

Store a client with a set of scopes as authorized for a given user.

Passed in scopes are merged with already accepted scopes for the given client.

Parameters

int $uid: The user ID.

string $client_id: The client ID.

string[] $scopes: List of scopes that shuld be authorized.

Overrides KnownClientsRepositoryInterface::rememberClient

File

src/KnownClientsRepository.php, line 47

Class

KnownClientsRepository
Default implementation for the known clients repository.

Namespace

Drupal\simple_oauth

Code

public function rememberClient($uid, $client_id, array $scopes) {
  $name = 'client:' . $client_id;
  $existing_scopes = (array) $this->userData
    ->get('simple_oauth', $uid, $name);
  $scopes = array_unique(array_merge($scopes, $existing_scopes));
  $this->userData
    ->set('simple_oauth', $uid, $name, $scopes);
}