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

$config = getGithubConfig();

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

header('Location: https://github.com/login/oauth/authorize?' . http_build_query([
    'client_id'    => $config['client_id'],
    'redirect_uri' => $config['redirect_uri'],
    'state'        => $state,
    'scope'        => 'user:email',
]));
exit;