class LinkedInAuthManager in Open Social 8.2
Same name and namespace in other branches
- 8.9 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager
- 8 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager
- 8.3 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager
- 8.4 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager
- 8.5 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager
- 8.6 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager
- 8.7 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager
- 8.8 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager
Class LinkedInAuthManager.
@package Drupal\social_auth_linkedin
Hierarchy
- class \Drupal\social_auth_extra\AuthManager implements AuthManagerInterface
- class \Drupal\social_auth_linkedin\LinkedInAuthManager
Expanded class hierarchy of LinkedInAuthManager
2 files declare their use of LinkedInAuthManager
- LinkedInAuthController.php in modules/
custom/ social_auth_linkedin/ src/ Controller/ LinkedInAuthController.php - LinkedInLinkController.php in modules/
custom/ social_auth_linkedin/ src/ Controller/ LinkedInLinkController.php
1 string reference to 'LinkedInAuthManager'
- social_auth_linkedin.services.yml in modules/
custom/ social_auth_linkedin/ social_auth_linkedin.services.yml - modules/custom/social_auth_linkedin/social_auth_linkedin.services.yml
1 service uses LinkedInAuthManager
- social_auth_linkedin.auth_manager in modules/
custom/ social_auth_linkedin/ social_auth_linkedin.services.yml - \Drupal\social_auth_linkedin\LinkedInAuthManager
File
- modules/
custom/ social_auth_linkedin/ src/ LinkedInAuthManager.php, line 16
Namespace
Drupal\social_auth_linkedinView source
class LinkedInAuthManager extends AuthManager {
/**
* {@inheritdoc}
*/
public function getSocialNetworkKey() {
return LinkedInAuthSettings::getSocialNetworkKey();
}
/**
* {@inheritdoc}
*/
public function setSdk($sdk) {
if (!$sdk instanceof LinkedIn) {
throw new InvalidArgumentException('SDK object should be instance of \\Happyr\\LinkedIn\\LinkedIn class');
}
$this->sdk = $sdk;
}
/**
* {@inheritdoc}
*/
public function getAuthenticationUrl($type, array $scope = [
'r_basicprofile',
'r_emailaddress',
]) {
return $this->sdk
->getLoginUrl([
'redirect_uri' => $this
->getRedirectUrl($type),
'scope' => implode(',', $scope),
]);
}
/**
* {@inheritdoc}
*/
public function getAccessToken($type = '') {
try {
$access_token = $this->sdk
->getAccessToken();
return $access_token;
} catch (LinkedInException $e) {
$this->loggerFactory
->get('social_auth_linkedin')
->error('Could not get LinkedIn access token. LinkedInException: @message', [
'@message' => $e
->getMessage(),
]);
return NULL;
}
if ($access_token) {
$this->sdk
->setAccessToken($access_token);
return $access_token;
}
$this->loggerFactory
->get('social_auth_linkedin')
->error('Could not get LinkedIn access token. User cancelled the dialog in Facebook or return URL was not valid.');
return NULL;
}
/**
* {@inheritdoc}
*/
public function getProfile() {
if (!$this->profile) {
if (($profile = $this->sdk
->get('v1/people/~:(id,firstName,lastName,email-address,formattedName,pictureUrls::(original))')) && !isset($profile['errorCode'])) {
$this->profile = $profile;
}
}
return $this->profile;
}
/**
* {@inheritdoc}
*/
public function getProfilePicture() {
if (!empty($this->profile['pictureUrls']['_total'])) {
return end($this->profile['pictureUrls']['values']);
}
}
/**
* {@inheritdoc}
*/
public function setAccessToken($access_token) {
$this->sdk
->setAccessToken($access_token);
}
/**
* {@inheritdoc}
*/
public function getAccountId() {
return isset($this->profile['id']) ? $this->profile['id'] : NULL;
}
/**
* {@inheritdoc}
*/
public function getFirstName() {
return isset($this->profile['firstName']) ? $this->profile['firstName'] : NULL;
}
/**
* {@inheritdoc}
*/
public function getLastName() {
return isset($this->profile['lastName']) ? $this->profile['lastName'] : NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AuthManager:: |
protected | property | ||
AuthManager:: |
protected | property | Contains the field definition with a profile picture. | |
AuthManager:: |
protected | property | ||
AuthManager:: |
protected | property | Contains object of a profile received from a social network. | |
AuthManager:: |
protected | property | Object of SDK to work with API of social network. | |
AuthManager:: |
protected | property | ||
AuthManager:: |
public | function |
Determines preferred profile pic resolution from account settings. Overrides AuthManagerInterface:: |
|
AuthManager:: |
public | function |
Returns URL to authorize/registration depending on type. Overrides AuthManagerInterface:: |
|
AuthManager:: |
public | function |
Returns user on a social network if it possible. Overrides AuthManagerInterface:: |
1 |
AuthManager:: |
public | function |
Set an instance of a field definition that contains picture. Overrides AuthManagerInterface:: |
|
AuthManager:: |
public | function | AuthManager constructor. | |
LinkedInAuthManager:: |
public | function |
Reads user's access token from social network. Overrides AuthManagerInterface:: |
|
LinkedInAuthManager:: |
public | function |
Returns an account ID on a social network. Overrides AuthManagerInterface:: |
|
LinkedInAuthManager:: |
public | function |
Returns the login URL where user will be redirected for authentication. Overrides AuthManagerInterface:: |
|
LinkedInAuthManager:: |
public | function |
Returns first name on a social network if it possible. Overrides AuthManagerInterface:: |
|
LinkedInAuthManager:: |
public | function |
Returns last name on a social network if it possible. Overrides AuthManagerInterface:: |
|
LinkedInAuthManager:: |
public | function |
Returns object of a user profile. Overrides AuthManagerInterface:: |
|
LinkedInAuthManager:: |
public | function |
Returns URL of a profile picture. Overrides AuthManagerInterface:: |
|
LinkedInAuthManager:: |
public | function |
Returns key-name of a social network. Overrides AuthManagerInterface:: |
|
LinkedInAuthManager:: |
public | function |
Set access token to AuthManager to use it for API calls. Overrides AuthManagerInterface:: |
|
LinkedInAuthManager:: |
public | function |
Set instance of SDK. Overrides AuthManagerInterface:: |