CURLOPT_PROXYUSERPWD(3)

πŸ’… CURLOPT_PROXYUSERPWD(3) β€” like, the proxy login page

okay bestie, this is <pink>CURLOPT_PROXYUSERPWD</pink> from the Library Functions Manual, and it's genuinely the glow-up your proxy connection has been waiting for ✨ It's all about the username + password combo you hand over when your HTTP proxy is like "who are you tho??" 🫢


✨ NAME ✨

CURLOPT_PROXYUSERPWD β€” the username and password you use for proxy authentication πŸ”


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYUSERPWD, char *userpwd);

πŸ¦‹ DESCRIPTION πŸ¦‹

So you pass in a char pointer as the parameter, and that string should be shaped like [username]:[password] β€” that's the creds for connecting to the HTTP proxy πŸ’…

Here's the part that lowkey trips people up: both the name and the password get URL decoded before they're used. So if you need an actual colon inside the username, you gotta encode it as %3A. And yes, this is different from how CURLOPT_USERPWD(3) works β€” beware, bestie, beware 😭

Wanna pick the auth method too? That's CURLOPT_PROXYAUTH(3), bestie, go off πŸ‘‘

Good news though: the application does not have to keep the string around after setting this option. Set it and forget it, main character energy 🧚

Set it multiple times? No stress β€” the last string you set overrides all the previous ones. And if you set it to NULL, that disables it again. Clean slate, periodt ✨


πŸŽ€ DEFAULT πŸŽ€

NULL


🌈 PROTOCOLS 🌈

This functionality affects all supported protocols β€” every single one, no cap πŸ‘‘


πŸ”₯ EXAMPLE πŸ”₯

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_PROXY, "http://localhost:8080");
    curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "clark%20kent:superman");
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

(not clark%20kent being Clark Kent, the man is literally flying under the radar, iconic πŸ¦Έβ€β™‚οΈπŸ’€)


⭐ AVAILABILITY ⭐

Added in curl 7.1 β€” a certified classic, she's been here a while πŸ’–


πŸ’œ RETURN VALUE πŸ’œ

curl_easy_setopt(3) returns a CURLcode that tells you whether it slayed or flopped:

  • CURLE_OK (0) β€” everything was OK, we ate πŸ“
  • non-zero β€” an error happened 😭 see libcurl-errors(3) for the details

🫢 SEE ALSO 🫢


and that's the whole page, bestie β€” brought to you by the good people of libcurl, version dated 2026-10-12, and this little doc is CURLOPT_PROXYUSERPWD(3). go authenticate something gorgeous πŸ’…βœ¨

πŸ“¦ where this page comes from