curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

libcurl in C++ Access Denied

From: Jeremy via curl-library <curl-library_at_lists.haxx.se>
Date: Thu, 29 Sep 2022 16:45:41 -0400

Hello,

Can someone please help me figure out the cURL library in C++? This is
the main part of the code I am trying:

     curl_easy_setopt(curl, CURLOPT_URL,
"https://api.somewhere.com/something/");
     curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
     curl_easy_setopt(curl, CURLOPT_USERPWD, "username:password");
     curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
     curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
     res = curl_easy_perform(curl);
     curl_easy_cleanup(curl);

However, it returns this message: "HTTP Basic: Access denied."

I also tried this with the same result:

         curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

This works:

     curl -u "username:password" https://api.somewhere.com/something/

Thank you

-Jeremy

-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2022-09-29