/**
  * @throws AbortException
  */
 public function actionAuthorize()
 {
     if (!$this->getHttpRequest()->isMethod(IRequest::GET)) {
         $body = $this->createStream();
         $body->write('Method not allowed');
         $this->sendResponse($this->createResponse()->withStatus(IResponse::S405_METHOD_NOT_ALLOWED)->withBody($body));
     }
     $response = $this->createResponse();
     try {
         $this->getSession(self::SESSION_NAMESPACE)->authorizationRequest = $this->authorizationRequestSerializer->serialize($this->authorizationServer->validateAuthorizationRequest($this->createServerRequest()));
         if (!$this->getUser()->isLoggedIn()) {
             $this->redirect(...$this->redirectConfig->getLoginDestination());
         }
         $this->redirect(...$this->redirectConfig->getApproveDestination());
     } catch (AbortException $e) {
         throw $e;
     } catch (OAuthServerException $e) {
         $this->sendResponse($e->generateHttpResponse($response));
     } catch (\Exception $e) {
         if ($this->logger) {
             $this->logger->error($e->getMessage(), ['exception' => $e]);
         }
         $body = $this->createStream();
         $body->write('Unknown error');
         $this->sendResponse($response->withStatus(IResponse::S500_INTERNAL_SERVER_ERROR)->withBody($body));
     }
 }