Implicit.php in Simple OAuth (OAuth2) & OpenID Connect 5.x
File
src/Plugin/Oauth2Grant/Implicit.php
View source
<?php
namespace Drupal\simple_oauth\Plugin\Oauth2Grant;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\simple_oauth\Plugin\Oauth2GrantBase;
use League\OAuth2\Server\Grant\ImplicitGrant;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Implicit extends Oauth2GrantBase {
protected $expiration;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory) {
$enabled = $config_factory
->get('simple_oauth.settings')
->get('use_implicit');
if (!$enabled) {
throw new PluginNotFoundException('implicit');
}
parent::__construct($configuration, $plugin_id, $plugin_definition);
$settings = $config_factory
->get('simple_oauth.settings');
$this->expiration = new \DateInterval(sprintf('PT%dS', $settings
->get('access_token_expiration')));
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'));
}
public function getGrantType() {
return new ImplicitGrant($this->expiration);
}
}