login.php 610 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. require_once __DIR__ . '/boot.inc';
  3. $app = boot();
  4. session_start();
  5. $client = new Google_Client();
  6. $client->setClientId($app['auth']['client_id']);
  7. $client->setClientSecret($app['auth']['client_secret']);
  8. $client->setRedirectUri('http://api.audean.com/login.php');
  9. if (isset($_GET['logout'])) {
  10. unset($_SESSION['token']);
  11. }
  12. if (isset($_GET['code'])) {
  13. echo "<p>Code received";
  14. $client->authenticate($_GET['code']);
  15. $_SESSION['token'] = $client->getAccessToken();
  16. }
  17. else {
  18. echo "<p>No code";
  19. }
  20. header('Location: http://' . $_SERVER['HTTP_HOST'] . '/simple.php');//$_SERVER['PHP_SELF']);