CURLOPT_USERPWD.3 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. .\" generated by cd2nroff 0.1 from CURLOPT_USERPWD.md
  2. .TH CURLOPT_USERPWD 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_USERPWD \- username and password to use in authentication
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERPWD, char *userpwd);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a char pointer as parameter, pointing to a null\-terminated login details
  12. string for the connection. The format of which is: [username]:[password].
  13. When using Kerberos V5 authentication with a Windows based server, you should
  14. specify the username part with the domain name in order for the server to
  15. successfully obtain a Kerberos Ticket. If you do not then the initial part of
  16. the authentication handshake may fail.
  17. When using NTLM, the username can be specified simply as the username without
  18. the domain name should the server be part of a single domain and forest.
  19. To specify the domain name use either Down\-Level Logon Name or UPN (User
  20. Principal Name) formats. For example \fBEXAMPLE\user\fP and \fBuser@example.com\fP
  21. respectively.
  22. Some HTTP servers (on Windows) support inclusion of the domain for Basic
  23. authentication as well.
  24. When using HTTP and \fICURLOPT_FOLLOWLOCATION(3)\fP, libcurl might perform several
  25. requests to possibly different hosts. libcurl only sends this user and
  26. password information to hosts using the initial hostname (unless
  27. \fICURLOPT_UNRESTRICTED_AUTH(3)\fP is set), so if libcurl follows redirects to other
  28. hosts, it does not send the user and password to those. This is enforced to
  29. prevent accidental information leakage.
  30. Use \fICURLOPT_HTTPAUTH(3)\fP to specify the authentication method for HTTP
  31. based connections or \fICURLOPT_LOGIN_OPTIONS(3)\fP to control IMAP, POP3 and
  32. SMTP options.
  33. The user and password strings are not URL decoded, so there is no way to send
  34. in a username containing a colon using this option. Use \fICURLOPT_USERNAME(3)\fP
  35. for that, or include it in the URL.
  36. The application does not have to keep the string around after setting this
  37. option.
  38. .SH DEFAULT
  39. NULL
  40. .SH PROTOCOLS
  41. This functionality affects all supported protocols
  42. .SH EXAMPLE
  43. .nf
  44. int main(void)
  45. {
  46. CURL *curl = curl_easy_init();
  47. if(curl) {
  48. CURLcode res;
  49. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  50. curl_easy_setopt(curl, CURLOPT_USERPWD, "clark:kent");
  51. res = curl_easy_perform(curl);
  52. curl_easy_cleanup(curl);
  53. }
  54. }
  55. .fi
  56. .SH AVAILABILITY
  57. Added in curl 7.1
  58. .SH RETURN VALUE
  59. Returns CURLE_OK on success or
  60. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  61. .SH SEE ALSO
  62. .BR CURLOPT_PASSWORD (3),
  63. .BR CURLOPT_PROXYUSERPWD (3),
  64. .BR CURLOPT_USERNAME (3)