You are here

public function GoogleAuth::initSdk in Open Social 8.6

Same name and namespace in other branches
  1. 8.9 modules/custom/social_auth_google/src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth::initSdk()
  2. 8 modules/custom/social_auth_google/src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth::initSdk()
  3. 8.2 modules/custom/social_auth_google/src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth::initSdk()
  4. 8.3 modules/custom/social_auth_google/src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth::initSdk()
  5. 8.4 modules/custom/social_auth_google/src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth::initSdk()
  6. 8.5 modules/custom/social_auth_google/src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth::initSdk()
  7. 8.7 modules/custom/social_auth_google/src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth::initSdk()
  8. 8.8 modules/custom/social_auth_google/src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth::initSdk()

Returns an instance of sdk.

Return value

mixed Returns a new Google Client instance or FALSE if the config was incorrect.

Throws

\Drupal\social_api\SocialApiException

File

modules/custom/social_auth_google/src/Plugin/Network/GoogleAuth.php, line 37

Class

GoogleAuth
Defines a Network Plugin for Social Auth Google.

Namespace

Drupal\social_auth_google\Plugin\Network

Code

public function initSdk() {
  $class_name = '\\Google_Client';
  if (!class_exists($class_name)) {
    throw new SocialApiException(sprintf('The PHP SDK for Google Services could not be found. Class: %s.', $class_name));
  }
  if (!$this
    ->validateConfig($this->settings)) {
    return FALSE;
  }
  $client = new $class_name();
  $client
    ->setClientId($this->settings
    ->getClientId());
  $client
    ->setClientSecret($this->settings
    ->getClientSecret());
  return $client;
}