//getGoogleData if ($vInfo->{'quarantine'}) { $this->voa_end_login("Sorry, you have been quarantined"); exit; } if ($vInfo->{'blacklisted'}) { $this->voa_end_login("Sorry, you have been blacklisted."); exit; } if (!$vInfo->{'verified'}) { $this->voa_end_login("Sorry, you are not verified yet."); exit; } $this->voa_login_user($oauth_identity); } catch (Exception $e) { echo $e->getMessage(); } } } else { $this->voa_end_login("Sorry, we couldn't log you in. Please notify the admin or try again later."); } } else { if (empty($_SESSION['VOA']['EXPIRES_AT']) || time() > $_SESSION['VOA']['EXPIRES_AT']) { $this->voa_clear_login_state(); } $state = uniqid('', true); $_SESSION['VOA']['STATE'] = md5($state); header("Location: " . $v->getAuthURL($state)); } //this seems to break something not allowing logging in....leaving in for eventual fix //$this->voa_end_login("Sorry, we couldn't log you in. The authentication flow terminated in an unexpected way. Please notify the admin or try again later.");
*/ $v->setClient("Your client here"); $v->setSecret("Your secret here"); $v->addScope(array("Add scopes here")); $v->setRedirect("redirect URL here"); if (isset($_GET['logout'])) { unset($_SESSION['vACCESS_TOKEN']); unset($_SESSION['vREFRESH']); } if (isset($_GET['code'])) { if ($_GET['state'] === md5('stateGoesHere')) { $v->setCode(trim($_GET['code'])); $_SESSION['vACCESS_TOKEN'] = $v->getToken("stateGoesHere"); $_SESSION['vREFRESH'] = $v->getRefreshToken(); } else { die("CSRF attack"); } //do something after login } elseif (isset($_SESSION['vACCESS_TOKEN'])) { //set token from session and use it to retrieve data $v->setToken($_SESSION['vACCESS_TOKEN']); try { $vInfo = $v->getVInfo(); echo "you are logged into v. Welcome back " . $vInfo->{'agent'}; } catch (Exception $e) { echo $e->getMessage(); } } else { //if not logged in, create auth url echo $auth = $v->getAuthURL("stateGoesHere"); }