public function Oauth2GrantManager::getAuthorizationServer in Simple OAuth (OAuth2) & OpenID Connect 8.2
Same name and namespace in other branches
- 8.4 src/Plugin/Oauth2GrantManager.php \Drupal\simple_oauth\Plugin\Oauth2GrantManager::getAuthorizationServer()
- 8.3 src/Plugin/Oauth2GrantManager.php \Drupal\simple_oauth\Plugin\Oauth2GrantManager::getAuthorizationServer()
- 5.x src/Plugin/Oauth2GrantManager.php \Drupal\simple_oauth\Plugin\Oauth2GrantManager::getAuthorizationServer()
Gets the authorization server.
Parameters
string $grant_type: The grant type used as plugin ID.
Return value
\League\OAuth2\Server\AuthorizationServer The authorization server.
Throws
\League\OAuth2\Server\Exception\OAuthServerException When the grant cannot be found.
Overrides Oauth2GrantManagerInterface::getAuthorizationServer
File
- src/Plugin/ Oauth2GrantManager.php, line 98 
Class
- Oauth2GrantManager
- Provides the OAuth2 Grant plugin manager.
Namespace
Drupal\simple_oauth\PluginCode
public function getAuthorizationServer($grant_type) {
  try {
    /** @var \Drupal\simple_oauth\Plugin\Oauth2GrantInterface $plugin */
    $plugin = $this
      ->createInstance($grant_type);
  } catch (PluginNotFoundException $exception) {
    throw OAuthServerException::invalidGrant('Check the configuration to see if the grant is enabled.');
  }
  $this
    ->checkKeyPaths();
  $salt = Settings::getHashSalt();
  $server = new AuthorizationServer($this->clientRepository, $this->accessTokenRepository, $this->scopeRepository, realpath($this->privateKeyPath), Core::ourSubstr($salt, 0, 32));
  // Enable the password grant on the server with a token TTL of X hours.
  $server
    ->enableGrantType($plugin
    ->getGrantType(), $this->expiration);
  return $server;
}