/** * @covers HealthGraph\Authorization::deauthorize * @todo Implement better testDeauthorize(). */ public function testDeauthorize() { $auth = new Authorization(); $result = $auth->deauthorize($this->authorization_code); $this->assertTrue($result); }
if (isset($_GET['code'])) { // user accepted access $token = Authorization::authorize($_GET['code'], $client_id, $client_secret, $redirect_url); if ($token) { $_SESSION['token'] = $token; } header("Location: {$redirect_url}"); } elseif (isset($_GET['error'])) { // user denied access $button = Authorization::getAuthorizationButton($client_id, $redirect_url); echo $button['html']; echo '<h2>Denied</h2>'; } elseif (isset($_GET['revoke'])) { // user wants to disconnect $auth = new Authorization(); if ($auth->deauthorize($token['access_token'])) { unset($_SESSION['token']); } header("Location: {$redirect_url}"); } elseif (!isset($token)) { // user is not connected $button = Authorization::getAuthorizationButton($client_id, $redirect_url); echo $button['html']; } else { // user is already connected echo "<a href='{$redirect_url}?revoke'>Disconnect</a>"; $hgc = Client::factory(array('access_token' => $token['access_token'], 'token_type' => $token['token_type'])); try { $profile = $hgc->getProfile()->getAll(); var_dump($profile); } catch (Exception $e) {