if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { $client->setAccessToken($_SESSION['access_token']); } else { $authUrl = $client->createAuthUrl(); } /************************************************ If we're signed in we can go ahead and retrieve the ID token, which is part of the bundle of data that is exchange in the authenticate step - we only need to do a network call if we have to retrieve the Google certificate to verify it, and that can be cached. ************************************************/ if ($client->getAccessToken()) { $_SESSION['access_token'] = $client->getAccessToken(); $token_data = $client->verifyIdToken()->getAttributes(); } echo pageHeader("User Query - Retrieving An Id Token"); if ($client_id == '<YOUR_CLIENT_ID>' || $client_secret == '<YOUR_CLIENT_SECRET>' || $redirect_uri == '<YOUR_REDIRECT_URI>') { echo missingClientSecretsWarning(); } ?> <div class="box"> <div class="request"> <?php if (isset($authUrl)) { echo "<a class='login' href='" . $authUrl . "'>Connect Me!</a>"; } else { echo "<a class='logout' href='?logout'>Logout</a>"; } ?>