public function LinkedInAuthManager::getAccessToken in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
- 8 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
- 8.2 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
- 8.3 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
- 8.4 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
- 8.5 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
- 8.6 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
- 8.7 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
Reads user's access token from social network.
Parameters
string $type: Type of action. "login" or "register".
Return value
object User's access token, if it could be read from social network. Null, otherwise.
Overrides AuthManagerInterface::getAccessToken
File
- modules/
custom/ social_auth_linkedin/ src/ LinkedInAuthManager.php, line 53
Class
- LinkedInAuthManager
- Class LinkedInAuthManager.
Namespace
Drupal\social_auth_linkedinCode
public function getAccessToken($type = '') {
try {
// Set the RedirectUrl before retrieving the access token.
$redirect_url = $this
->getRedirectUrl($type);
$this->sdk
->setRedirectUrl($redirect_url);
$access_token = $this->sdk
->getAccessToken($_GET['code']);
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 LinkedIn or return URL was not valid.');
return NULL;
}