You are here

public function LinkedInAuthManager::getAccessToken in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
  2. 8.2 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
  3. 8.3 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
  4. 8.4 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
  5. 8.5 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
  6. 8.6 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
  7. 8.7 modules/custom/social_auth_linkedin/src/LinkedInAuthManager.php \Drupal\social_auth_linkedin\LinkedInAuthManager::getAccessToken()
  8. 8.8 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 49

Class

LinkedInAuthManager
Class LinkedInAuthManager.

Namespace

Drupal\social_auth_linkedin

Code

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;
}