23 lines
665 B
PHP
23 lines
665 B
PHP
<?php
|
|
session_start();
|
|
require_once 'google_config.php';
|
|
|
|
// If we have an access token, the user is already connected.
|
|
if (isset($_SESSION['access_token'])) {
|
|
header('Location: index.php');
|
|
exit();
|
|
}
|
|
|
|
$auth_url = 'https://accounts.google.com/o/oauth2/v2/auth?' . http_build_query([
|
|
'client_id' => GOOGLE_CLIENT_ID,
|
|
'redirect_uri' => GOOGLE_REDIRECT_URI,
|
|
'response_type' => 'code',
|
|
'scope' => 'https://www.googleapis.com/auth/calendar.readonly',
|
|
'access_type' => 'offline', // Required to get a refresh token
|
|
'prompt' => 'consent' // Forces the consent screen to be shown every time
|
|
]);
|
|
|
|
header('Location: ' . $auth_url);
|
|
exit();
|
|
?>
|