EPO patent php curl oauth, i do not manage to get data out - OPS

https://www.epo.org/

I try to get data out of the OPS system using PHP cURL functions http://php.net/manual/en/ref.curl.php. This to allow usage of oauth2 authentication.

I managed to create a token and store its data locally using the following functions:

<HTML>
<HEAD></HEAD>
<BODY>
<?php
function read_token ($tokenname) {

    $tokenfile="./tokens/$tokenname.dat";
    $error='';
    if (file_exists($tokenfile)) {
        $token=unserialize(file_get_contents($tokenfile));
// convert token issued time from windows (milliseconds) format to unix (seconds) format
        $tokentime=substr($token['issued_at'],0,-3);
        $tokenduration=$tokentime + $token['expires_in'] - 120;
        if ($tokenduration < time()) {
            $error.="token '$tokenname' expired.<br>\n";
        } else {
            $token['error']=$error;
        }
    } else {
        $error.="tokenfile '$tokenname' not found.<br>\n";
    }
    if ($error) {$token=create_token($tokenname);}
    return($token);
}

function create_token ($tokenname) {
// set variables
    $tokenfile="./tokens/$tokenname.dat";
    $error='';
    switch ($tokenname) {
        case 'OPSincidental':
            $ops_key='--mykey--';
            $ops_secret='--mysecret--';
            break;
        default:
            $ops_key='';
            $ops_secret='';
            break;

    }
    $tokenUrl='https://ops.epo.org/3.1/auth/accesstoken';
    $tokenHeaders=array(
        'Authorization: Basic '.base64_encode($ops_key.':'.$ops_secret),
        'Content-Type: application/x-www-form-urlencoded'
    );
    $tokenPostFields='grant_type=client_credentials';

    $curlOpts=array(
        CURLOPT_URL => $tokenUrl,
        CURLOPT_HTTPHEADER => $tokenHeaders,
        CURLOPT_POSTFIELDS => $tokenPostFields,
        CURLOPT_POST => 1,
        CURLOPT_RETURNTRANSFER => 1
    );

// obtain token
    $token_request= curl_init();
    curl_setopt_array($token_request, $curlOpts);
    if (!$ops_token_response=curl_exec($token_request)) {$error.=curl_error($token_request)."<br>\n";}
    curl_close($token_request);

// process token
    $ops_token_split=explode(',', trim($ops_token_response,'{}'));
    foreach ($ops_token_split as $tokenval) {
        $tokenpair=explode(' : ', trim($tokenval));
        $token[trim($tokenpair[0],'"')]=trim($tokenpair[1],'"');
    }

// write token data to file
    file_put_contents($tokenfile, serialize($token));

// add error information to token array and return result
    $token['error']=$error;
    return($token);
}
$token=read_token('OPSincidental');
if (!$token['error']) {
    echo "Token:<br>\n<PRE>"; print_r($token); echo "</PRE>";

// prepare for sending data request
    $error='';
    $requestUrl='http://ops.epo.org/3.1/rest-services/published-data/publication/epodoc/EP1000000';
    $requestHeaders=array(
        'Authorization: Bearer '.$token['access_token'],
        'Host: ops.epo.org',
        'X-Target-URI: http://ops.epo.org',
        'Accept: application/xml',
        'Connection: Keep-Alive'
    );

    $curlOpts=array(
        CURLOPT_URL => $requestUrl,
        CURLOPT_HTTPHEADER => $requestHeaders,
//          CURLOPT_SSL_VERIFYPEER => FALSE,
//          CURLOPT_SSL_VERIFYHOST => FALSE,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_HEADER => 1
    );

// send request and collect data
    $ops_request= curl_init();
    curl_setopt_array($ops_request, $curlOpts);
    if (!$ops_response=curl_exec($ops_request)) { $error.=curl_error($ops_request)."<br>\n";}
    echo "curl options:<br>\n";
    echo "<PRE>";print_r($requestHeaders);echo "</PRE>";
    curl_close($ops_request);


    if ($error) {echo "Error:<br>\n$error";} else {echo "Result:<br>\n".htmlspecialchars($ops_response);}
} else {
    echo $token['error'];
}
?>
</BODY>
</HTML>

The code correctly reads the token as stored. However the result I receive is just a response header, no response data. The header response is as follows

Result:
HTTP/1.1 400 Bad Request Date: Sat, 18 Jan 2020 08:56:44 GMT Content-Type: application/xml Content-Length: 129 Connection: keep-alive WWW-Authenticate: Bearer realm="null",error="invalid_token",error_description="oauth.v2.InvalidAccessToken: Invalid access token" Access-Control-Allow-Methods: POST Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Authorization <error><code>400</code><message>invalid_access_token</message><description>Access token is invalid</description> </error> string(514) "HTTP/1.1 400 Bad Request Date: Sat, 18 Jan 2020 08:56:44 GMT Content-Type: application/xml Content-Length: 129 Connection: keep-alive WWW-Authenticate: Bearer realm="null",error="invalid_token",error_description="oauth.v2.InvalidAccessToken: Invalid access token" Access-Control-Allow-Methods: POST Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Authorization 400invalid_access_tokenAccess token is invalid "