<?php
ini_set('display_errors', '0');
error_reporting(E_ALL);
require_once dirname(__FILE__) . '/../config.php';

echo "=== Test de autenticación ===\n";
echo "REQUEST_METHOD: " . $_SERVER['REQUEST_METHOD'] . "\n";
echo "HTTP_AUTHORIZATION: " . ($_SERVER['HTTP_AUTHORIZATION'] ?? 'NO SET') . "\n";
echo "REDIRECT_HTTP_AUTHORIZATION: " . ($_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ?? 'NO SET') . "\n";

// Simular lo que hace productos.php
if ($_SERVER['REQUEST_METHOD'] !== 'GET') { 
    echo "ERROR: No es GET\n";
    exit;
}

echo "Llamando a auth()...\n";
try {
    $jwt = auth();
    echo "Auth OK: " . json_encode($jwt) . "\n";
} catch (Exception $e) {
    echo "Exception: " . $e->getMessage() . "\n";
}
