You are here

protected function Oauth::getOauthClient in Entity Share 8.3

Helper function to initialize the OAuth client provider.

Parameters

string $url: URL to request.

array $credentials: Trial credentials.

Return value

\League\OAuth2\Client\Provider\GenericProvider An OAuth client provider.

2 calls to Oauth::getOauthClient()
Oauth::getAccessToken in modules/entity_share_client/src/Plugin/ClientAuthorization/Oauth.php
Obtains the stored or renewed access token based on expiration state.
Oauth::initializeToken in modules/entity_share_client/src/Plugin/ClientAuthorization/Oauth.php
Helper function to initialize a token.

File

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

Class

Oauth
Provides Oauth2 based client authorization.

Namespace

Drupal\entity_share_client\Plugin\ClientAuthorization

Code

protected function getOauthClient(string $url, array $credentials) {
  $oauth_client = new GenericProvider([
    'clientId' => $credentials['client_id'],
    'clientSecret' => $credentials['client_secret'],
    'urlAuthorize' => $url . $credentials['authorization_path'],
    'urlAccessToken' => $url . $credentials['token_path'],
    'urlResourceOwnerDetails' => '',
  ], [
    // Force our own HTTP Client to have overridden settings from
    // setting.php taken into account.
    'httpClient' => $this->httpClientFactory
      ->fromOptions(),
  ]);
  return $oauth_client;
}