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

Reply via email to