CURLOPT_PASSWORD(3)
π CURLOPT_PASSWORD(3) β like, the password you use for auth, bestie
okay so real quick, this is a page from the libcurl library functions manual and it's about CURLOPT_PASSWORD, which is genuinely one of the most self-explanatory names in all of curl. but we're still gonna go through it together because that's what besties do π«Ά
β¨ NAME β¨
CURLOPT_PASSWORD β the password to use in authentication. that's it. that's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PASSWORD, char *pwd);
π¦ DESCRIPTION π¦
so you pass a char pointer as the parameter, and that pointer should be pointing at a null-terminated password string you wanna use for the transfer. literally just the password. that's the assignment. π
the CURLOPT_PASSWORD(3) option is meant to be used in conjunction with the CURLOPT_USERNAME(3) option β like, they're a matching set, you don't really send a password at nobody, y'know? it's giving duo energy. π―ββοΈ
good news for your memory management anxiety: the application does not have to keep the string around after setting this option. curl takes care of it. you can let it go. β¨
if you use this option multiple times, the last set string overrides the previous ones β last one wins, no cap. and if you set it to NULL, that disables its use again. so NULL is the "never mind, forget the password" move. π
π DEFAULT π
blank β like, nothing. empty. no password. the void. π
π PROTOCOLS π
this functionality affects all supported protocols. all of them. every single one. we love an inclusive icon π
π EXAMPLE π
here's a whole little main that logs in with the password qwerty (please don't actually use qwerty, but that's what the example says so I'm not touching it):
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "qwerty");
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
β AVAILABILITY β
added in curl 7.19.1 β so it's been serving looks for a very long time π°οΈ
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode that indicates success or error.
CURLE_OK (0) means everything was ok β slay. non-zero means an error occurred β not slay. see libcurl-errors(3) for the full tea on what went wrong. π
π₯ SEE ALSO π₯
and that's the whole page bestie, hope your auth works first try π§ββοΈ
mwah π β this has been libcurl, dated 2026-10-12, and yes the page itself is CURLOPT_PASSWORD(3) the whole way through π
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms