You are here

public function OAuth2Storage::getClientDetails in OAuth2 Server 2.0.x

Same name and namespace in other branches
  1. 8 src/OAuth2Storage.php \Drupal\oauth2_server\OAuth2Storage::getClientDetails()

Get client credentials.

Parameters

string $client_id: The client id string.

Return value

array|bool|\Drupal\oauth2_server\Entity\Client An client array.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

3 calls to OAuth2Storage::getClientDetails()
OAuth2Storage::checkClientCredentials in src/OAuth2Storage.php
Check client credentials.
OAuth2Storage::getClientKey in src/OAuth2Storage.php
Get client key.
OAuth2Storage::isPublicClient in src/OAuth2Storage.php
Is public client.

File

src/OAuth2Storage.php, line 240

Class

OAuth2Storage
Provides Drupal OAuth2 storage for the library.

Namespace

Drupal\oauth2_server

Code

public function getClientDetails($client_id) {

  /** @var \Drupal\oauth2_server\ClientInterface $client */
  $client = $this
    ->getStorageClient($client_id);
  if ($client) {

    // Return a client array in the format expected by the library.
    $client = [
      'client_id' => $client->client_id,
      'client_secret' => $client->client_secret,
      'public_key' => $client->public_key,
      // The library expects multiple redirect uris to be separated by
      // a space, but the module separates them by a newline, matching
      // Drupal behavior in other areas.
      'redirect_uri' => str_replace([
        "\r\n",
        "\r",
        "\n",
      ], ' ', $client->redirect_uri),
    ];
  }
  return $client;
}