You are here

abstract class OAuth2Manager in Social Auth 3.x

Same name and namespace in other branches
  1. 8.2 src/AuthManager/OAuth2Manager.php \Drupal\social_auth\AuthManager\OAuth2Manager
  2. 8 src/AuthManager/OAuth2Manager.php \Drupal\social_auth\AuthManager\OAuth2Manager

Defines a basic OAuth2Manager.

@package Drupal\social_auth

Hierarchy

Expanded class hierarchy of OAuth2Manager

File

src/AuthManager/OAuth2Manager.php, line 12

Namespace

Drupal\social_auth\AuthManager
View source
abstract class OAuth2Manager extends BaseOAuth2Manager implements OAuth2ManagerInterface {

  /**
   * The scopes to be requested.
   *
   * @var string|null
   */
  protected $scopes;

  /**
   * The end points to be requested.
   *
   * @var string|null
   */
  protected $endPoints;

  /**
   * The user returned by the provider.
   *
   * @var \League\OAuth2\Client\Provider\GenericResourceOwner|array|mixed
   */
  protected $user;

  /**
   * {@inheritdoc}
   */
  public function getExtraDetails($method = 'GET', $domain = NULL) {
    $endpoints = $this
      ->getEndPoints();

    // Stores the data mapped with endpoints define in settings.
    $data = [];
    if ($endpoints) {

      // Iterates through endpoints define in settings and retrieves them.
      foreach (explode(PHP_EOL, $endpoints) as $endpoint) {

        // Endpoint is set as path/to/endpoint|name.
        $parts = explode('|', $endpoint);
        $data[$parts[1]] = $this
          ->requestEndPoint($method, $parts[0], $domain);
      }
      return $data;
    }
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getScopes() {
    if ($this->scopes === NULL) {
      $this->scopes = $this->settings
        ->get('scopes');
    }
    return $this->scopes;
  }

  /**
   * {@inheritdoc}
   */
  public function getEndPoints() {
    if ($this->endPoints === NULL) {
      $this->endPoints = $this->settings
        ->get('endpoints');
    }
    return $this->endPoints;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OAuth2Manager::$accessToken protected property Access token for OAuth2 authentication.
OAuth2Manager::$client protected property The service client.
OAuth2Manager::$endPoints protected property The end points to be requested.
OAuth2Manager::$loggerFactory protected property The logger factory.
OAuth2Manager::$request protected property The current request.
OAuth2Manager::$scopes protected property The scopes to be requested.
OAuth2Manager::$settings protected property Social Auth implementer settings.
OAuth2Manager::$user protected property The user returned by the provider. Overrides OAuth2Manager::$user
OAuth2Manager::getAccessToken public function Gets the access token after authentication. Overrides OAuth2ManagerInterface::getAccessToken
OAuth2Manager::getClient public function Gets the service client object. Overrides OAuth2ManagerInterface::getClient
OAuth2Manager::getEndPoints public function Gets the API endpoints to be requested. Overrides OAuth2ManagerInterface::getEndPoints
OAuth2Manager::getExtraDetails public function Request data from the declared endpoints. Overrides OAuth2ManagerInterface::getExtraDetails
OAuth2Manager::getScopes public function Gets the scopes defined in the settings form. Overrides OAuth2ManagerInterface::getScopes
OAuth2Manager::setAccessToken public function Sets the access token. Overrides OAuth2ManagerInterface::setAccessToken
OAuth2Manager::setClient public function Sets the provider client. Overrides OAuth2ManagerInterface::setClient
OAuth2Manager::__construct public function OAuth2Manager Constructor.
OAuth2ManagerInterface::authenticate public function Authenticates the user.
OAuth2ManagerInterface::getAuthorizationUrl public function Returns the authorization URL where user will be redirected.
OAuth2ManagerInterface::getState public function Returns OAuth2 state.
OAuth2ManagerInterface::getUserInfo public function Gets data about the user.
OAuth2ManagerInterface::requestEndPoint public function Request and end point.