public function __construct(\OAuth2\Response $response) { $this->response = $response; $this->code = $response->getStatusCode(); $this->description = $response->getStatusText(); $this->message = $response->getResponseBody(); }
/** * Constructor. * @param Response $response * @param \Exception $previous The previous exception used for the exception chaining. */ public function __construct(Response $response, \Exception $previous = null) { if ((int) $response->getStatusCode() == 401) { $errorCode = $response->getParameter('error', 'required_token'); $message = $response->getParameter('error_description', 'An Access Token is required.'); } else { $errorCode = $response->getParameter('error', 'unknown'); $message = $response->getParameter('error_description', $response->getStatusText()); } $this->errorCode = $errorCode; $this->errorUri = $response->getParameter('error_uri'); return parent::__construct($response->getStatusCode(), $message, 0, $previous); }
protected function handleResponse(OAuth2Response $response) { $redirect = $response->getHttpHeader('Location'); if (!empty($redirect)) { return $this->redirect()->toUrl($redirect); } $parameters = $response->getParameters(); $errorUri = isset($parameters['error_uri']) ? $parameters['error_uri'] : null; $view = new ViewModel(array('statusCode' => $response->getStatusCode(), 'statusText' => $response->getStatusText(), 'errorDescription' => $parameters['error_description'], 'error' => $parameters['error'], 'errorUri' => $errorUri)); $view->setTemplate('kap-security/oauth-authorize-error'); return $view; }