You are here

public function Oauth::getJsonApiClient in Entity Share 8.3

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

Parameters

string $url: The remote url.

Return value

\GuzzleHttp\Client The HTTP client.

Overrides ClientAuthorizationInterface::getJsonApiClient

File

modules/entity_share_client/src/Plugin/ClientAuthorization/Oauth.php, line 148

Class

Oauth
Provides Oauth2 based client authorization.

Namespace

Drupal\entity_share_client\Plugin\ClientAuthorization

Code

public function getJsonApiClient($url) {
  $token = $this
    ->getAccessToken($url);
  return $this->httpClientFactory
    ->fromOptions([
    'base_uri' => $url . '/',
    'headers' => [
      'Content-type' => 'application/vnd.api+json',
      'Authorization' => 'Bearer ' . $token,
    ],
  ]);
}