protected function FacebookAuth::initSdk in Social Auth Facebook 8.2
Same name and namespace in other branches
- 8 src/Plugin/Network/FacebookAuth.php \Drupal\social_auth_facebook\Plugin\Network\FacebookAuth::initSdk()
- 3.x src/Plugin/Network/FacebookAuth.php \Drupal\social_auth_facebook\Plugin\Network\FacebookAuth::initSdk()
Sets the underlying SDK library.
Return value
\League\OAuth2\Client\Provider\Facebook|false The initialized 3rd party library instance. False if library could not be initialized.
Throws
\Drupal\social_api\SocialApiException If the SDK library does not exist.
File
- src/
Plugin/ Network/ FacebookAuth.php, line 40
Class
- FacebookAuth
- Defines a Network Plugin for Social Auth Facebook.
Namespace
Drupal\social_auth_facebook\Plugin\NetworkCode
protected function initSdk() {
$class_name = '\\League\\OAuth2\\Client\\Provider\\Facebook';
if (!class_exists($class_name)) {
throw new SocialApiException(sprintf('The PHP League OAuth2 library for Facebook not found. Class: %s.', $class_name));
}
/** @var \Drupal\social_auth_facebook\Settings\FacebookAuthSettings $settings */
$settings = $this->settings;
if ($this
->validateConfig($settings)) {
// All these settings are mandatory.
$league_settings = [
'clientId' => $settings
->getAppId(),
'clientSecret' => $settings
->getAppSecret(),
'redirectUri' => Url::fromRoute('social_auth_facebook.callback')
->setAbsolute()
->toString(),
'graphApiVersion' => 'v' . $settings
->getGraphVersion(),
];
// Proxy configuration data for outward proxy.
$proxyUrl = $this->siteSettings
->get('http_client_config')['proxy']['http'];
if ($proxyUrl) {
$league_settings['proxy'] = $proxyUrl;
}
return new Facebook($league_settings);
}
return FALSE;
}