I cant get a token from an authorization code

Hello,
I already have the client ID and client secret both encrypted in base64 and set as an “Authorization: Basic” header just like in wikipedia. I can get the code from the user but when I do a POST request to “https://api.faceit.com/auth/v1/oauth/token” the array comes back as null.
Here is the code I used:

function get_oauth2_token($code) {
    global $client_id;
    global $client_secret;
    $auth = $client_id . ":" . $client_secret;
    $encoded = base64_encode($auth);

    $oauth2token_url = "https://api.faceit.com/auth/v1/oauth/token";
    $clienttoken_post = array(
        "Authorization" => "Basic " . $encoded,
        "code" => $code,
        "grant_type" => "authorization_code"
    );

    $curl = curl_init($oauth2token_url);

    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $clienttoken_post);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $json_response = curl_exec($curl);
    curl_close($curl);

    $authObj = json_decode($json_response);
    
    if (!isset($authObj)) {
        die("No response");
    }

    if (isset($authObj->refresh_token)){
        //refresh token only granted on first authorization for offline access
        //save to db for future use (db saving not included in example)
        global $refreshToken;
        $refreshToken = $authObj->refresh_token;
    }
    
    

    $accessToken = $authObj->access_token;
    return $accessToken;
}

I get “No response”, meaning isset($authObj) is false.

Can anyone help me?