function checkAuthResult() { $code = getVariable('code', FALSE); $state = getVariable('state', FALSE); $oauthUnguessable = getSessionVariable('oauthUnguessable', null); if (!$code || !$state || !$oauthUnguessable) { return; } if ($state != $oauthUnguessable) { //Miss-match on what we're tring to validated. echo "Miss-match on secret'"; return; } try { $api = new \AABTest\GithubAPI\GithubAPI(); $command = $api->accessToken(GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, $code, "http://" . SERVER_HOSTNAME . "/github/return.php"); $response = $command->execute(); setSessionVariable('githubAccess', $response); echo "You are now authed for the following scopes:<br/>"; foreach ($response->scopes as $scope) { echo $scope . "<br/>"; } } catch (\AABTest\GithubAPI\GithubAPIException $fae) { echo "Exception processing response: " . $fae->getMessage(); } }