CURLINFO_HTTPAUTH_USED(3)

πŸ’… CURLINFO_HTTPAUTH_USED(3) β€” ok so which auth did we ACTUALLY use bestie

hey so this is a page from the Library Functions Manual (libcurl, the one and only 🫢), and it's about CURLINFO_HTTPAUTH_USED β€” literally the "so what auth method did we end up using" getter. no cap, it's a vibe.


✨ NAME ✨

CURLINFO_HTTPAUTH_USED β€” the used HTTP authentication method πŸ”


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_USED, long *authp);

✨ DESCRIPTION ✨

okay so picture this: you pass in a pointer to a long, and that long gets filled with a bitmask telling you which authentication method was used in the previous HTTP request. πŸŽ€

the meaning of the possible bits? it's all explained over in the CURLOPT_HTTPAUTH(3) option for curl_easy_setopt(3) β€” go read that bestie, it's the whole lore.

and here's the cute part: the returned value has zero or one bit set. so it's giving "it's either this or nothing, no messy in-betweens" πŸ’…


✨ PROTOCOLS ✨

this functionality affects http only πŸ¦‹


✨ EXAMPLE ✨

here's the whole thing, verbatim, slay:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC | CURLAUTH_DIGEST);
    curl_easy_setopt(curl, CURLOPT_USERNAME, "shrek");
    curl_easy_setopt(curl, CURLOPT_PASSWORD, "swamp");

    result = curl_easy_perform(curl);

    if(!result) {
      long auth;
      result = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_USED, &auth);
      if(!result) {
        if(!auth)
          printf("No auth used\n");
        else {
          if(auth == CURLAUTH_DIGEST)
            printf("Used Digest authentication\n");
          else
            printf("Used Basic authentication\n");
        }
      }
    }
    curl_easy_cleanup(curl);
  }
}

and yes, the credentials are literally shrek / swamp. iconic. ogres have excellent security posture apparently πŸ‘‘πŸŸ’


✨ AVAILABILITY ✨

added in curl 8.12.0 β€” so if you're on something ancient, bestie, it's not you, it's the version 😭


✨ RETURN VALUE ✨

curl_easy_getinfo(3) returns a CURLcode indicating success or error. that's the whole vibe check.

  • CURLE_OK (0) means everything was OK πŸ’–
  • non-zero means an error occurred β€” check libcurl-errors(3) for the full tea β˜•

✨ SEE ALSO ✨


okay that's the page!! 🌈 go forth and find out what auth your request actually used, bestie. and remember the footer lore: this was libcurl, dated 2026-10-12 β€” so like, future us wrote this and it still slaps πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from