%PDF- %PDF-
| Direktori : /data/www_bck/varak.net_bck/suiteshooters.varak.net/www/ |
| Current File : //data/www_bck/varak.net_bck/suiteshooters.varak.net/www/oauth2callback.php |
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ .'/../lib/googleClient');
require_once 'vendor/autoload.php';
session_start();
$client = new Google_Client();
$client->setAuthConfigFile(__DIR__ . '/../client_secret_605290507813-bi1u4msh2ps5bl969qdbma18gk2mihp1.apps.googleusercontent.com.json');
$client->setRedirectUri('https://' . $_SERVER['HTTP_HOST'] . '/oauth2callback.php');
$client->addScope(Google_Service_Oauth2::USERINFO_EMAIL);
$client->addScope(Google_Service_Oauth2::USERINFO_PROFILE);
if (! isset($_GET['code'])) {
$auth_url = $client->createAuthUrl();
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
} else {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
$redirect_uri = 'https://' . $_SERVER['HTTP_HOST'] . '/';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}