static function auth() { $tokenInfo = getTokenInfo($_GET['code']); if (isset($tokenInfo['access_token'])) { $params['access_token'] = $tokenInfo['access_token']; $userInfo = json_decode(file_get_contents('https://www.googleapis.com/oauth2/v1/userinfo' . '?' . urldecode(http_build_query($params))), true); if (isset($userInfo['id'])) { $userInfo = $userInfo; $result = true; } $_SESSION['user'] = $userInfo; redirect_to('/'); } }
<html> <head> <style> body { margin:0; } div { width:75%;margin-left:10px;padding:5px;font-family: "Courier New"; } div#tokenstats { border-bottom:5px solid;background-color:#99ccff;margin:0 0 10px 0;padding:5px;width:100%; } .code { margin:5px 0 5px 10px;background-color:#eee; } div.data{ height:600px;border:1px solid;overflow:auto; } </style> </head> <body> <div id="tokenstats"> <b>Token info</b>: <?php echo getTokenInfo($client); ?> <br> <b>Session Token</b>: <?php echo $client->getAuthSubToken(); ?> <br> </div> <?php // ============================================================================= // Return the user's entire profile in a single atom <entry> // ============================================================================= try { $snippet = ' // =========================================================================