public function callbackAction()
 {
     $authService = $this->getAuthenticationService();
     $state = $authService->decodeJwt($this->params()->fromQuery('state'));
     if (!$state) {
         throw new \InvalidArgumentException("Can't decode state from jwt token");
     }
     //TODO check params
     //if(empty($state['service']) || empty($state['requestParams']) || empty($state['service']))
     $service = $state['service'];
     $requestParams = $state['requestParams'];
     $adapter = $this->getAdapter($service);
     $result = $authService->authenticate($adapter);
     if (!$result->isValid()) {
         $response = new OAuth2Response();
         $redirectUri = $requestParams['redirect_uri'];
         if ($redirectUri) {
             $response->setRedirect(302, $redirectUri, $requestParams['state'], 'authentication_failed', current($result->getMessages()), null);
         } else {
             $response->setError(400, 'authentication_failed', current($result->getMessages()));
         }
         return $this->handleResponse($response);
     }
     $request = $this->getOAuth2Request($state['requestParams']);
     return $this->authorize($request);
 }