id; if (isset($_GET["logout"])) { session_destroy(); header('Location: ' . $_SERVER['PHP_SELF']); } } else { if (isset($_GET['login'])) { getLogin(); } else if (isset($_GET["code"])) { if (!isset($_GET['state']) || $_SESSION['state'] != $_GET['state']) { header('Location: ' . $_SERVER['PHP_SELF']); die(); } // Exchange the auth code for a token $token = apiRequest("https://github.com/login/oauth/access_token", array( 'client_id' => $GITHUB_CLIENT_ID, 'client_secret' => $GITHUB_CLIENT_SECRET, 'redirect_uri' => $HTTP_PROTO . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'], 'state' => $_SESSION['state'], 'code' => $_GET['code'] )); $_SESSION['access_token'] = $token->access_token; header('Location: ' . $_SERVER['PHP_SELF']); } } ?>