public function GoogleAuthController::getProfile in Open Social 8.4
Same name and namespace in other branches
- 8.9 modules/custom/social_auth_google/src/Controller/GoogleAuthController.php \Drupal\social_auth_google\Controller\GoogleAuthController::getProfile()
- 8 modules/custom/social_auth_google/src/Controller/GoogleAuthController.php \Drupal\social_auth_google\Controller\GoogleAuthController::getProfile()
- 8.2 modules/custom/social_auth_google/src/Controller/GoogleAuthController.php \Drupal\social_auth_google\Controller\GoogleAuthController::getProfile()
- 8.3 modules/custom/social_auth_google/src/Controller/GoogleAuthController.php \Drupal\social_auth_google\Controller\GoogleAuthController::getProfile()
- 8.5 modules/custom/social_auth_google/src/Controller/GoogleAuthController.php \Drupal\social_auth_google\Controller\GoogleAuthController::getProfile()
- 8.6 modules/custom/social_auth_google/src/Controller/GoogleAuthController.php \Drupal\social_auth_google\Controller\GoogleAuthController::getProfile()
- 8.7 modules/custom/social_auth_google/src/Controller/GoogleAuthController.php \Drupal\social_auth_google\Controller\GoogleAuthController::getProfile()
- 8.8 modules/custom/social_auth_google/src/Controller/GoogleAuthController.php \Drupal\social_auth_google\Controller\GoogleAuthController::getProfile()
Loads access token, then loads profile.
Parameters
string $type: The type.
Return value
object Returns an object.
2 calls to GoogleAuthController::getProfile()
- GoogleAuthController::userLoginCallback in modules/
custom/ social_auth_google/ src/ Controller/ GoogleAuthController.php - Authorizes the user after redirect from Google.
- GoogleAuthController::userRegisterCallback in modules/
custom/ social_auth_google/ src/ Controller/ GoogleAuthController.php - Registers the new account after redirect from Google.
File
- modules/
custom/ social_auth_google/ src/ Controller/ GoogleAuthController.php, line 230
Class
- GoogleAuthController
- Class GoogleAuthController.
Namespace
Drupal\social_auth_google\ControllerCode
public function getProfile($type) {
// Get the OAuth token from Google.
if (!($access_token = $this->authManager
->getAccessToken($type))) {
drupal_set_message($this
->t('@network login failed. Token is not valid.', [
'@network' => $this
->t('Google'),
]), 'error');
return $this
->redirect('user.' . $type);
}
// Get user's Google profile from Google API.
if (!($profile = $this->authManager
->getProfile()) || !$profile
->getId()) {
drupal_set_message($this
->t('@network login failed, could not load @network profile. Contact the site administrator.', [
'@network' => $this
->t('Google'),
]), 'error');
return $this
->redirect('user.' . $type);
}
$this->accessToken = $access_token;
return $profile;
}