You are here

class ResourceOwnerExample in OAuth2 Client 8.3

Resource Owner example plugin.

Plugin annotation


@Oauth2Client(
  id = "resource_owner_example",
  name = @Translation("Resource Owner Example"),
  grant_type = "resource_owner",
  authorization_uri = "http://example.com/oauth/token",
  token_uri = "http://example.com/oauth/token",
  resource_owner_uri = "",
)

Hierarchy

Expanded class hierarchy of ResourceOwnerExample

File

examples/oauth2_client_example_plugins/src/Plugin/Oauth2Client/ResourceOwnerExample.php, line 20

Namespace

Drupal\oauth2_client_example_plugins\Plugin\Oauth2Client
View source
class ResourceOwnerExample extends Oauth2ClientPluginBase {

  /*
   * This example assumes that the Drupal site is using a shared resource
   * from a third-party service that provides a service to all uses of the site.
   *
   * Storing a single AccessToken in state for the plugin shares access to the
   * external resource for ALL users of this plugin.
   */

  /**
   * {@inheritdoc}
   */
  public function storeAccessToken(AccessToken $accessToken) {
    $this->state
      ->set('oauth2_client_access_token-' . $this
      ->getId(), $accessToken);
  }

  /**
   * {@inheritdoc}
   */
  public function retrieveAccessToken() {
    return $this->state
      ->get('oauth2_client_access_token-' . $this
      ->getId());
  }

  /**
   * {@inheritdoc}
   */
  public function clearAccessToken() {
    $this->state
      ->delete('oauth2_client_access_token-' . $this
      ->getId());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
Oauth2ClientPluginBase::$configFactory protected property The configuration factory.
Oauth2ClientPluginBase::$credentials private property Storage for credentials retrieved from credential service.
Oauth2ClientPluginBase::$credentialService protected property Injected credential service.
Oauth2ClientPluginBase::$messenger protected property The messenger service. Overrides MessengerTrait::$messenger
Oauth2ClientPluginBase::$state protected property The Drupal state api.
Oauth2ClientPluginBase::$uuid protected property Injected UUID service.
Oauth2ClientPluginBase::buildConfigurationForm public function Form constructor. Overrides PluginFormInterface::buildConfigurationForm
Oauth2ClientPluginBase::checkKeyDefined private function Check that a key is defined when requested. Throw an exception if not.
Oauth2ClientPluginBase::clearCredentials private function Helper function to clear cached credentials.
Oauth2ClientPluginBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 2
Oauth2ClientPluginBase::defaultConfiguration public function Gets default configuration for this plugin. Overrides ConfigurableInterface::defaultConfiguration
Oauth2ClientPluginBase::displaySuccessMessage public function Check the plugin definition for success_message or return a static value. Overrides Oauth2ClientPluginInterface::displaySuccessMessage
Oauth2ClientPluginBase::expandedProviderOptions protected function Helper method to build the credential provider elements of the form.
Oauth2ClientPluginBase::getAuthorizationUri public function Retrieves the authorization_uri of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getAuthorizationUri
Oauth2ClientPluginBase::getClientId public function Retrieves the client_id of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getClientId
Oauth2ClientPluginBase::getClientSecret public function Retrieves the client_secret of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getClientSecret
Oauth2ClientPluginBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
Oauth2ClientPluginBase::getCredentialProvider public function Returns the plugin credentials if they are set, otherwise returns NULL. Overrides Oauth2ClientPluginInterface::getCredentialProvider
Oauth2ClientPluginBase::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
Oauth2ClientPluginBase::getGrantType public function Retrieves the grant type of the plugin. Overrides Oauth2ClientPluginInterface::getGrantType
Oauth2ClientPluginBase::getId public function Retrieves the id of the OAuth2 Client plugin. Overrides Oauth2ClientPluginInterface::getId
Oauth2ClientPluginBase::getName public function Retrieves the human-readable name of the Oauth2 Client plugin. Overrides Oauth2ClientPluginInterface::getName
Oauth2ClientPluginBase::getRedirectUri public function Retrieves the redirect_uri of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getRedirectUri
Oauth2ClientPluginBase::getResourceUri public function Retrieves the resource_uri of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getResourceUri
Oauth2ClientPluginBase::getScopes public function Get the set of scopes for the provider to use by default. Overrides Oauth2ClientPluginInterface::getScopes
Oauth2ClientPluginBase::getScopeSeparator public function Get the separator used to join the scopes in the OAuth2 query string. Overrides Oauth2ClientPluginInterface::getScopeSeparator
Oauth2ClientPluginBase::getStorageKey public function Returns the credential storage key if it is set, otherwise returns NULL. Overrides Oauth2ClientPluginInterface::getStorageKey
Oauth2ClientPluginBase::getTokenUri public function Retrieves the token_uri of the OAuth2 server. Overrides Oauth2ClientPluginInterface::getTokenUri
Oauth2ClientPluginBase::loadConfiguration protected function Helper function to initialize the internal configuration array.
Oauth2ClientPluginBase::retrieveCredentials private function Helper function to retrieve and cache credentials.
Oauth2ClientPluginBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
Oauth2ClientPluginBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm
Oauth2ClientPluginBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm
Oauth2ClientPluginBase::__construct final public function Constructs a Oauth2ClientPluginBase object. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
ResourceOwnerExample::clearAccessToken public function Clears the access token from storage. Overrides Oauth2ClientPluginInterface::clearAccessToken
ResourceOwnerExample::retrieveAccessToken public function Retrieve the access token storage. Overrides Oauth2ClientPluginInterface::retrieveAccessToken
ResourceOwnerExample::storeAccessToken public function Stores access tokens obtained by this client. Overrides Oauth2ClientPluginInterface::storeAccessToken
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.