<?php
$url = 'https://ose.efact.pe/api-efact-ose/oauth/token';
$data = http_build_query([
    'username'   => '20610220593',
    'password'   => '1863b8b76bde2940acef05012092b17cdac4e81fd81fbf04d2667d4f166ac0b2',
    'grant_type' => 'password'
]);
//
$headers = [
    'Authorization: Basic Y2xpZW50OnNlY3JldA==',
    'Content-Type: application/x-www-form-urlencoded',
    'Content-Length: ' . strlen($data)
];
//
$options = [
    'http' => [
        'method'  => 'POST',
        'header'  => implode("\r\n", $headers),
        'content' => $data,
        'ignore_errors' => true // Para capturar respuesta incluso en error HTTP
    ]
];
//
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
//
if ($response === false) {
    echo "Error en la solicitud.";
} else {
    echo $response;
}
?>