Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to solve the error "Authentication credentials were not provided" while running a CURL get request in php?

I am trying to hit a CURL "GET" request in php but getting the error as "Authentication credentials were not provided". So I cannot understand for which exact reason, the error is showing. Can anyone help?

$api_token = "test";
    $question_id = "test1";
    $organization_id = "test2";
    $thumbnail_file_path = "";


    $request_headers=array();
    $request_headers[]='Authorization: f'.$api_token;
    $request_headers[]='Content-Type: application/json';
    $request_headers[]='organization_id:'.$organization_id;


    $url="https//www.xyz.com/{$question_id}";
    // return $payloadName;

    $process = curl_init();
    curl_setopt($process, CURLOPT_HTTPHEADER, $request_headers);
    curl_setopt($process, CURLOPT_URL,$url);
    curl_setopt($process, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    $output = curl_exec($process);

    

    echo $output;
    
    $err = curl_error($process);
    // get info about the request
    $info = curl_getinfo($process);
    print_r($info);
    curl_close($process);

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Are you sure f in Authorization header is necessary? Looks like a typo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading