I am trying to authenticate against a HTTPS URL with “user name and password” using C-based curl API’s and curl command line arguments in linux (Fedora 14 curl 7.30.0 (i686-pc-linux-gnu) libcurl/7.30.0 OpenSSL/1.0.0 zlib/1.2.5
) ) platform.
When I use the URL in the Mozilla web browser it prompts for the username, password once – after I press “OK” I am able to get the content. But if I press the cancel button, “Login Cancelled by User” is shown. The error (screenshot) is attached.
How to authenticate and avoid “Login cancelled by user” exception using curl API’s and command line arguments?
Below are the options I have tried, but still the error remains the same – “Login cancelled by user”
Command Line:
curl -k --user "xxxxx:xxxxx" "https://fsgpos.opensoft.co.bw/ipa/statement/get/LN001234"
Curl API:
curl_easy_setopt(curl, CURLOPT_USERNAME,"xxxxxxxx"); curl_easy_setopt(curl, CURLOPT_PASSWORD,"xxxxxxxx");
How to handle this exception with valid curl options and API arguments?
Advertisement
Answer
Use UserAgent
string with your curl. This is the only thing you are missing compare to the browser.
-A "Mozilla 6.0"
Also, add the -v
parameter also, and show us the debug message of curl.