class GoogleAuth in Social Auth Google 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth
- 8 src/Plugin/Network/GoogleAuth.php \Drupal\social_auth_google\Plugin\Network\GoogleAuth
Defines a Network Plugin for Social Auth Google.
@package Drupal\social_auth_google\Plugin\Network
Plugin annotation
@Network(
id = "social_auth_google",
social_network = "Google",
type = "social_auth",
handlers = {
"settings": {
"class": "\Drupal\social_auth_google\Settings\GoogleAuthSettings",
"config_id": "social_auth_google.settings"
}
}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\social_api\Plugin\NetworkBase implements NetworkInterface
- class \Drupal\social_auth\Plugin\Network\NetworkBase implements NetworkInterface
- class \Drupal\social_auth_google\Plugin\Network\GoogleAuth implements GoogleAuthInterface
- class \Drupal\social_auth\Plugin\Network\NetworkBase implements NetworkInterface
- class \Drupal\social_api\Plugin\NetworkBase implements NetworkInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of GoogleAuth
File
- src/
Plugin/ Network/ GoogleAuth.php, line 28
Namespace
Drupal\social_auth_google\Plugin\NetworkView source
class GoogleAuth extends NetworkBase implements GoogleAuthInterface {
/**
* Sets the underlying SDK library.
*
* @return \League\OAuth2\Client\Provider\Google|false
* The initialized 3rd party library instance.
* False if library could not be initialized.
*
* @throws \Drupal\social_api\SocialApiException
* If the SDK library does not exist.
*/
protected function initSdk() {
$class_name = '\\League\\OAuth2\\Client\\Provider\\Google';
if (!class_exists($class_name)) {
throw new SocialApiException(sprintf('The Google library for PHP League OAuth2 not found. Class: %s.', $class_name));
}
/** @var \Drupal\social_auth_google\Settings\GoogleAuthSettings $settings */
$settings = $this->settings;
if ($this
->validateConfig($settings)) {
// All these settings are mandatory.
$league_settings = [
'clientId' => $settings
->getClientId(),
'clientSecret' => $settings
->getClientSecret(),
'redirectUri' => Url::fromRoute('social_auth_google.callback')
->setAbsolute()
->toString(),
'accessType' => 'offline',
'verify' => FALSE,
'hostedDomain' => $settings
->getRestrictedDomain() == '' ? NULL : $settings
->getRestrictedDomain(),
];
// Proxy configuration data for outward proxy.
$config = $this->siteSettings
->get('http_client_config');
if (!empty($config['proxy']['http'])) {
$league_settings['proxy'] = $config['proxy']['http'];
}
return new Google($league_settings);
}
return FALSE;
}
/**
* Checks that module is configured.
*
* @param \Drupal\social_auth_google\Settings\GoogleAuthSettings $settings
* The Google auth settings.
*
* @return bool
* True if module is configured.
* False otherwise.
*/
protected function validateConfig(GoogleAuthSettings $settings) {
$client_id = $settings
->getClientId();
$client_secret = $settings
->getClientSecret();
if (!$client_id || !$client_secret) {
$this->loggerFactory
->get('social_auth_google')
->error('Define Client ID and Client Secret on module settings.');
return FALSE;
}
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
GoogleAuth:: |
protected | function |
Sets the underlying SDK library. Overrides NetworkBase:: |
|
GoogleAuth:: |
protected | function | Checks that module is configured. | |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
NetworkBase:: |
protected | property | The entity type manager. | |
NetworkBase:: |
protected | property | The logger factory. | |
NetworkBase:: |
protected | property | The SDK client. | |
NetworkBase:: |
protected | property | The implementer/plugin settings. | |
NetworkBase:: |
protected | property | The global site settings. | |
NetworkBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
NetworkBase:: |
public | function |
Gets the underlying SDK library. Overrides NetworkInterface:: |
|
NetworkBase:: |
protected | function | Initialize the plugin. | |
NetworkBase:: |
public | function |
Instantiates a NetworkBase object. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |