class GoogleAuthManager in Open Social 8.2
Same name and namespace in other branches
- 8.9 modules/custom/social_auth_google/src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager
- 8 modules/custom/social_auth_google/src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager
- 8.3 modules/custom/social_auth_google/src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager
- 8.4 modules/custom/social_auth_google/src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager
- 8.5 modules/custom/social_auth_google/src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager
- 8.6 modules/custom/social_auth_google/src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager
- 8.7 modules/custom/social_auth_google/src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager
- 8.8 modules/custom/social_auth_google/src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager
Class GoogleAuthManager.
@package Drupal\social_auth_google
Hierarchy
- class \Drupal\social_auth_extra\AuthManager implements AuthManagerInterface
- class \Drupal\social_auth_google\GoogleAuthManager
Expanded class hierarchy of GoogleAuthManager
2 files declare their use of GoogleAuthManager
- GoogleAuthController.php in modules/
custom/ social_auth_google/ src/ Controller/ GoogleAuthController.php - GoogleLinkController.php in modules/
custom/ social_auth_google/ src/ Controller/ GoogleLinkController.php
1 string reference to 'GoogleAuthManager'
- social_auth_google.services.yml in modules/
custom/ social_auth_google/ social_auth_google.services.yml - modules/custom/social_auth_google/social_auth_google.services.yml
1 service uses GoogleAuthManager
- social_auth_google.auth_manager in modules/
custom/ social_auth_google/ social_auth_google.services.yml - \Drupal\social_auth_google\GoogleAuthManager
File
- modules/
custom/ social_auth_google/ src/ GoogleAuthManager.php, line 14
Namespace
Drupal\social_auth_googleView source
class GoogleAuthManager extends AuthManager {
/**
* Holds the Google Service.
*
* @var \Google_Service_Oauth2
*/
private $googleService;
/**
* {@inheritdoc}
*/
public function getSocialNetworkKey() {
return GoogleAuthSettings::getSocialNetworkKey();
}
/**
* {@inheritdoc}
*/
public function setSdk($sdk) {
if (!$sdk instanceof \Google_Client) {
throw new InvalidArgumentException('SDK object should be instance of \\Google_Client class');
}
$this->sdk = $sdk;
}
/**
* {@inheritdoc}
*/
public function getAuthenticationUrl($type, array $scope = [
'profile',
'email',
]) {
$redirect_url = $this
->getRedirectUrl($type);
$this->sdk
->setRedirectUri($redirect_url);
return $this->sdk
->createAuthUrl($scope);
}
/**
* {@inheritdoc}
*/
public function getProfilePicture() {
return $this->profile
->getPicture();
}
/**
* {@inheritdoc}
*/
public function getAccessToken($type) {
$redirect_url = $this
->getRedirectUrl($type);
$this->sdk
->setRedirectUri($redirect_url);
return $this->sdk
->authenticate(\Drupal::request()
->get('code'));
}
/**
* {@inheritdoc}
*/
public function getProfile() {
if (empty($this->googleService)) {
$this->googleService = new \Google_Service_Oauth2($this->sdk);
}
$this->profile = $this->googleService->userinfo
->get();
return $this->profile;
}
/**
* {@inheritdoc}
*/
public function setAccessToken($access_token) {
$this->sdk
->setAccessToken($access_token);
}
/**
* {@inheritdoc}
*/
public function getAccountId() {
return $this->profile
->getId();
}
/**
* {@inheritdoc}
*/
public function getFirstName() {
return $this->profile
->getGivenName();
}
/**
* {@inheritdoc}
*/
public function getLastName() {
return $this->profile
->getFamilyName();
}
}
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. | |
GoogleAuthManager:: |
private | property | Holds the Google Service. | |
GoogleAuthManager:: |
public | function |
Reads user's access token from social network. Overrides AuthManagerInterface:: |
|
GoogleAuthManager:: |
public | function |
Returns an account ID on a social network. Overrides AuthManagerInterface:: |
|
GoogleAuthManager:: |
public | function |
Returns the login URL where user will be redirected for authentication. Overrides AuthManagerInterface:: |
|
GoogleAuthManager:: |
public | function |
Returns first name on a social network if it possible. Overrides AuthManagerInterface:: |
|
GoogleAuthManager:: |
public | function |
Returns last name on a social network if it possible. Overrides AuthManagerInterface:: |
|
GoogleAuthManager:: |
public | function |
Returns object of a user profile. Overrides AuthManagerInterface:: |
|
GoogleAuthManager:: |
public | function |
Returns URL of a profile picture. Overrides AuthManagerInterface:: |
|
GoogleAuthManager:: |
public | function |
Returns key-name of a social network. Overrides AuthManagerInterface:: |
|
GoogleAuthManager:: |
public | function |
Set access token to AuthManager to use it for API calls. Overrides AuthManagerInterface:: |
|
GoogleAuthManager:: |
public | function |
Set instance of SDK. Overrides AuthManagerInterface:: |