/**
  * @param UserInterface $user
  * @param AuthorizeFormHandler $formHandler
  *
  * @return Response
  */
 protected function processSuccess(UserInterface $user, AuthorizeFormHandler $formHandler)
 {
     if (true === $this->container->get('session')->get('_fos_oauth_server.ensure_logout')) {
         $this->container->get('security.context')->setToken(null);
         $this->container->get('session')->invalidate();
     }
     $this->container->get('event_dispatcher')->dispatch(OAuthEvent::POST_AUTHORIZATION_PROCESS, new OAuthEvent($user, $this->getClient(), $formHandler->isAccepted()));
     try {
         return $this->container->get('fos_oauth_server.server')->finishClientAuthorization($formHandler->isAccepted(), $user, null, $formHandler->getScope());
     } catch (OAuth2ServerException $e) {
         return $e->getHttpResponse();
     }
 }
 /**
  * @param UserInterface        $user
  * @param AuthorizeFormHandler $formHandler
  * @param Request              $request
  *
  * @return Response
  */
 protected function processSuccess(UserInterface $user, AuthorizeFormHandler $formHandler, Request $request)
 {
     if (true === $this->container->get('session')->get('_fos_oauth_server.ensure_logout')) {
         $this->getTokenStorage()->setToken(null);
         $this->container->get('session')->invalidate();
     }
     $this->container->get('event_dispatcher')->dispatch(OAuthEvent::POST_AUTHORIZATION_PROCESS, new OAuthEvent($user, $this->getClient(), $formHandler->isAccepted()));
     $formName = $this->container->get('fos_oauth_server.authorize.form')->getName();
     if (!$request->query->all() && $request->request->has($formName)) {
         $request->query->add($request->request->get($formName));
     }
     try {
         return $this->container->get('fos_oauth_server.server')->finishClientAuthorization($formHandler->isAccepted(), $user, $request, $formHandler->getScope());
     } catch (OAuth2ServerException $e) {
         return $e->getHttpResponse();
     }
 }