You are here

public function Header::getClient in Entity Share 8.3

Prepares a guzzle client for http operations with the supported auth.

Parameters

string $url: The url to set in the client.

Return value

\GuzzleHttp\Client The HTTP client.

Overrides ClientAuthorizationInterface::getClient

File

modules/entity_share_client/src/Plugin/ClientAuthorization/Header.php, line 30

Class

Header
Provides Header based client authorization.

Namespace

Drupal\entity_share_client\Plugin\ClientAuthorization

Code

public function getClient($url) {
  $credentials = $this->keyService
    ->getCredentials($this);
  return $this->httpClientFactory
    ->fromOptions([
    'base_uri' => $url . '/',
    'cookies' => TRUE,
    'allow_redirects' => TRUE,
    'headers' => [
      $credentials['header_name'] => $credentials['header_value'],
    ],
  ]);
}