1CURLOPT_USERPWD(3) curl_easy_setopt options CURLOPT_USERPWD(3)
2
3
4
6 CURLOPT_USERPWD - user name and password to use in authentication
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERPWD, char *userpwd);
12
14 Pass a char * as parameter, pointing to a null-terminated login details
15 string for the connection. The format of which is: [user name]:[pass‐
16 word].
17
18 When using Kerberos V5 authentication with a Windows based server, you
19 should specify the user name part with the domain name in order for the
20 server to successfully obtain a Kerberos Ticket. If you do not then the
21 initial part of the authentication handshake may fail.
22
23 When using NTLM, the user name can be specified simply as the user name
24 without the domain name should the server be part of a single domain
25 and forest.
26
27 To specify the domain name use either Down-Level Logon Name or UPN
28 (User Principal Name) formats. For example, EXAMPLE\user and user@exam‐
29 ple.com respectively.
30
31 Some HTTP servers (on Windows) support inclusion of the domain for Ba‐
32 sic authentication as well.
33
34 When using HTTP and CURLOPT_FOLLOWLOCATION(3), libcurl might perform
35 several requests to possibly different hosts. libcurl will only send
36 this user and password information to hosts using the initial host name
37 (unless CURLOPT_UNRESTRICTED_AUTH(3) is set), so if libcurl follows lo‐
38 cations to other hosts it will not send the user and password to those.
39 This is enforced to prevent accidental information leakage.
40
41 Use CURLOPT_HTTPAUTH(3) to specify the authentication method for HTTP
42 based connections or CURLOPT_LOGIN_OPTIONS(3) to control IMAP, POP3 and
43 SMTP options.
44
45 The user and password strings are not URL decoded, so there's no way to
46 send in a user name containing a colon using this option. Use CUR‐
47 LOPT_USERNAME(3) for that, or include it in the URL.
48
49 The application does not have to keep the string around after setting
50 this option.
51
53 NULL
54
56 Most
57
59 CURL *curl = curl_easy_init();
60 if(curl) {
61 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
62
63 curl_easy_setopt(curl, CURLOPT_USERPWD, "clark:kent");
64
65 ret = curl_easy_perform(curl);
66
67 curl_easy_cleanup(curl);
68 }
69
71 Always
72
74 Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insuf‐
75 ficient heap space.
76
78 CURLOPT_USERNAME(3), CURLOPT_PASSWORD(3), CURLOPT_PROXYUSERPWD(3),
79
80
81
82libcurl 7.85.0 May 17, 2022 CURLOPT_USERPWD(3)