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