public function callback_google()
 {
     $client = GoogleHelper::getClient();
     if (!isset($_GET['code'])) {
         $auth_url = GoogleHelper::getAuthUrl($client);
         header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
     } else {
         GoogleHelper::authenticate($client, $_GET['code']);
         unset($_SESSION['code']);
         //$client->authenticate($_GET['code']);
         $accessToken = GoogleHelper::getAccessToken($client);
         $_SESSION['access_token'] = $accessToken;
         if (isset($accessToken->refresh_token)) {
             $client = GoogleHelper::refreshToken($client, $accessToken);
         }
         $_SESSION['client'] = serialize($client);
         //carga el perfil del usuario identificado
         require dirname(__FILE__) . '/contactsController.php';
         $controller = new contactsController();
         $controller->getUser();
         $this->login_google();
     }
 }
Esempio n. 2
0
<?php

/**
*   I believe this was only needed to set up the oauth config for the google contacts api.
*/
$app->get('/gauth', function () use($app) {
    $client = GoogleHelper::getClient();
    GoogleHelper::authenticate($client, $_GET['code']);
    // $app['session']->set('google_auth_code', $_GET['code']);
    return $app->redirect('/');
});