<?php
require_once dirname(__DIR__) . '/config.php';
require_once dirname(__DIR__) . '/includes/gitee_config.php';

$state = bin2hex(random_bytes(16));
$_SESSION['gitee_state'] = $state;

$auth_url = 'https://gitee.com/oauth/authorize?' . http_build_query([
    'client_id' => GITEE_CLIENT_ID,
    'redirect_uri' => GITEE_REDIRECT_URI,
    'response_type' => 'code',
    'state' => $state
]);

header('Location: ' . $auth_url);
exit;