<?php
/**
 * Inicia el flujo OAuth2 con Google.
 * Scopes requeridos: Drive (crear carpetas/archivos) + Sheets (leer/escribir)
 */
require_once __DIR__ . '/../config/config.php';

$params = [
    'client_id'     => GOOGLE_CLIENT_ID,
    'redirect_uri'  => GOOGLE_REDIRECT_URI,
    'response_type' => 'code',
    'scope'         => implode(' ', [
        'https://www.googleapis.com/auth/drive.file',
        'https://www.googleapis.com/auth/spreadsheets',
    ]),
    'access_type'   => 'offline',
    'prompt'        => 'consent',
];

header('Location: https://accounts.google.com/o/oauth2/v2/auth?' . http_build_query($params));
exit;
