/**
  * {@inheritdoc}
  */
 public function grantAuthorization(Authorization $authorization)
 {
     $code = $this->getAuthCodeManager()->createAuthCode($authorization->getClient(), $authorization->getEndUser(), $authorization->getQueryParams(), $authorization->getRedirectUri(), $authorization->getScope(), $authorization->getIssueRefreshToken());
     $params = ['code' => $code->getToken()];
     if (null !== $authorization->getState()) {
         $params['state'] = $authorization->getState();
     }
     return $params;
 }
 /**
  * {@inheritdoc}
  */
 public function grantAuthorization(Authorization $authorization)
 {
     $token = $this->getAccessTokenManager()->createAccessToken($authorization->getClient(), $authorization->getEndUser(), $authorization->getScope());
     $params = [];
     $state = $authorization->getState();
     if (!empty($state)) {
         $params['state'] = $state;
     }
     return $params;
 }
 protected function checkScope(Authorization &$authorization)
 {
     try {
         $scope = $this->getScopeManager()->checkScopePolicy($authorization->getClient(), $authorization->getScope());
         $authorization->setScope($scope);
     } catch (BaseExceptionInterface $e) {
         throw $e;
     } catch (\Exception $e) {
         throw $this->getExceptionManager()->getException(ExceptionManagerInterface::BAD_REQUEST, $e->getMessage());
     }
     $availableScopes = $this->getScopeManager()->getAvailableScopes($authorization->getClient());
     if (!$this->getScopeManager()->checkScopes($scope, $availableScopes)) {
         throw $this->getExceptionManager()->getException(ExceptionManagerInterface::BAD_REQUEST, ExceptionManagerInterface::INVALID_SCOPE, 'An unsupported scope was requested. Available scopes for the client are [' . implode(',', $availableScopes) . ']');
     }
 }