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