public function FacebookAuthManager::getAccessToken in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getAccessToken()
- 8.2 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getAccessToken()
- 8.3 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getAccessToken()
- 8.4 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getAccessToken()
- 8.5 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getAccessToken()
- 8.6 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getAccessToken()
- 8.7 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getAccessToken()
- 8.8 modules/custom/social_auth_facebook/src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::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_facebook/ src/ FacebookAuthManager.php, line 49
Class
- FacebookAuthManager
- Class FacebookAuthManager.
Namespace
Drupal\social_auth_facebookCode
public function getAccessToken($type) {
$helper = $this->sdk
->getRedirectLoginHelper();
$redirect_url = $this
->getRedirectUrl($type);
try {
$access_token = $helper
->getAccessToken($redirect_url);
} catch (FacebookResponseException $e) {
$this->loggerFactory
->get('social_auth_facebook')
->error('Could not get Facebook access token. FacebookResponseException: @message', [
'@message' => $e
->getMessage(),
]);
return NULL;
} catch (FacebookSDKException $e) {
$this->loggerFactory
->get('social_auth_facebook')
->error('Could not get Facebook access token. FacebookSDKException: @message', [
'@message' => $e
->getMessage(),
]);
return NULL;
}
if ($access_token) {
$this->sdk
->setDefaultAccessToken($access_token);
return $access_token;
}
$this->loggerFactory
->get('social_auth_facebook')
->error('Could not get Facebook access token. User cancelled the dialog in Facebook or return URL was not valid.');
return NULL;
}