$_SESSION['state'] = sha(uniqid(rand(), true)); $GitHubAuth->state = $_SESSION['state']; $GitHubAuth->authenticate(); } else { if (isset($_SESSION['state'], $_GET['state']) && $_SESSION['state'] == $_GET['state']) { unset($_SESSION['state']); $GitHubAuth->callback(function ($return) { $_SESSION['git_access_token'] = OAuth2::parseToken($return); header('Location: /examples/oauth/github.php'); exit; }); } else { header('Location: /examples/oauth/error.php'); exit; } } } else {