You are here

public function OAuth2Storage::setJti in OAuth2 Server 8

Same name and namespace in other branches
  1. 2.0.x src/OAuth2Storage.php \Drupal\oauth2_server\OAuth2Storage::setJti()

Set Jti.

Parameters

string $client_id: The client id string.

string $subject: The subject string.

string $audience: The audience string.

int $expires: The expiration timestamp.

string $jti: The jti string.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

File

src/OAuth2Storage.php, line 657

Class

OAuth2Storage
Provides Drupal OAuth2 storage for the library.

Namespace

Drupal\oauth2_server

Code

public function setJti($client_id, $subject, $audience, $expires, $jti) {
  $client = $this
    ->getStorageClient($client_id);
  if (!$client) {

    // The client_id should be validated prior to this method being called,
    // but the library doesn't do that currently.
    return;
  }
  $entity = $this->entityTypeManager
    ->getStorage('oauth2_server_jti')
    ->create([
    'client_id' => $client
      ->id(),
    'subject' => $subject,
    'jti' => $jti,
    'expires' => $expires,
  ]);
  $entity
    ->save();
}