public function onLoad() { parent::onLoad(); try { $error = $this->getParameter('error'); // error detection if (!empty($error)) { AuthorizationAbstract::throwErrorException($this->request->getUri()->getParameters()); } $code = $this->getParameter('code'); $state = $this->getParameter('state'); if (empty($code)) { throw new Exception('Code not available'); } $redirectUri = ''; // get access token $accessToken = $this->getAuthorizationCode($code, $state)->getAccessToken($code, $redirectUri); $this->onAccessToken($accessToken); } catch (ErrorExceptionAbstract $e) { $this->onError($e); } }
/** * * @expectedException \PSX\Oauth2\Authorization\Exception\InvalidRequestException */ public function testFacebookErrorException() { AuthorizationAbstract::throwErrorException(array('error' => array('message' => 'Message describing the error', 'type' => 'OAuthException', 'code' => 190, 'error_subcode' => 460))); }