You are here

abstract class OAuth2Manager in Social API 3.x

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

Defines basic OAuth2Manager to be used by social auth and social post.

@package Drupal\social_api

Hierarchy

Expanded class hierarchy of OAuth2Manager

File

src/AuthManager/OAuth2Manager.php, line 14

Namespace

Drupal\social_api\AuthManager
View source
abstract class OAuth2Manager implements OAuth2ManagerInterface {

  /**
   * The service client.
   *
   * @var \League\OAuth2\Client\Provider\AbstractProvider|mixed
   */
  protected $client;

  /**
   * Access token for OAuth2 authentication.
   *
   * @var \League\OAuth2\Client\Token\AccessToken|string|mixed
   */
  protected $accessToken;

  /**
   * Social Auth implementer settings.
   *
   * @var \Drupal\Core\Config\ImmutableConfig
   */
  protected $settings;

  /**
   * The logger factory.
   *
   * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
   */
  protected $loggerFactory;

  /**
   * The current request.
   *
   * @var \Symfony\Component\HttpFoundation\Request|null
   */
  protected $request;

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

  /**
   * OAuth2Manager Constructor.
   *
   * @param \Drupal\Core\Config\ImmutableConfig $settings
   *   The implementer settings.
   * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
   *   The logger factory.
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The current request.
   */
  public function __construct(ImmutableConfig $settings, LoggerChannelFactoryInterface $logger_factory, Request $request = NULL) {
    $this->settings = $settings;
    $this->loggerFactory = $logger_factory;
    $this->request = $request;
  }

  /**
   * {@inheritdoc}
   */
  public function setClient($client) {
    $this->client = $client;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getClient() {
    return $this->client;
  }

  /**
   * {@inheritdoc}
   */
  public function getAccessToken() {
    return $this->accessToken;
  }

  /**
   * {@inheritdoc}
   */
  public function setAccessToken($access_token) {
    $this->accessToken = $access_token;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OAuth2Manager::$accessToken protected property Access token for OAuth2 authentication.
OAuth2Manager::$client protected property The service client.
OAuth2Manager::$loggerFactory protected property The logger factory.
OAuth2Manager::$request protected property The current request.
OAuth2Manager::$settings protected property Social Auth implementer settings.
OAuth2Manager::$user protected property The user returned by the provider.
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::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.