CURLOPT_SASL_AUTHZID(3)

✨ CURLOPT_SASL_AUTHZID πŸ’…

okay bestie, so this one is a libcurl manpage β€” it's CURLOPT_SASL_AUTHZID(3) from the Library Functions Manual, and it's literally about telling the server "hey, I wanna act as this identity" πŸŽ€


🌸 NAME 🌸

CURLOPT_SASL_AUTHZID β€” the authorization identity, aka the identity you wanna act as πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SASL_AUTHZID, char *authzid);

πŸ’– DESCRIPTION πŸ’–

So you pass a char pointer as the parameter, and it should point to the null-terminated authorization identity (authzid) for the transfer. It's only applicable to the PLAIN SASL authentication mechanism, where it's optional β€” like, cute but not mandatory, iykyk ✨

When you don't specify it, only the authentication identity (authcid) β€” the one specified by the username β€” gets sent to the server, along with the password. The server then derives an authzid from the authcid when it's not provided, and uses that internally. no cap, it just figures it out itself 🧚

When the authzid is specified β€” and the use of it is server dependent, lowkey important β€” it can be used to access another user's inbox that the user has been granted access to, or a shared mailbox, for example. it's giving "let me peek in the group mailbox" energy πŸ™ˆ

The application does not have to keep the string around after setting this option. so you can free it, bestie, it's fine 🫢

Using this option multiple times makes the last set string override the previous ones. And set it to NULL to disable its use again β€” poof, gone πŸ’€


⭐ DEFAULT ⭐

blank


🌈 PROTOCOLS 🌈

This functionality affects imap only. like, literally only imap, don't try it elsewhere 😭


πŸ”₯ EXAMPLE πŸ”₯

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "imap://example.com/");
    curl_easy_setopt(curl, CURLOPT_USERNAME, "Kurt");
    curl_easy_setopt(curl, CURLOPT_PASSWORD, "xipj3plmq");
    curl_easy_setopt(curl, CURLOPT_SASL_AUTHZID, "Ursel");
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

Kurt's logging in, but acting as Ursel β€” main character behavior honestly πŸ‘‘βœ¨


πŸŽ€ AVAILABILITY πŸŽ€

Added in curl 7.66.0 β€” so if you're on something ancient, that's why it's not working, ngl πŸ¦‹


πŸ’œ RETURN VALUE πŸ’œ

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK β€” slay πŸ’… β€” and non-zero means an error occurred. see libcurl-errors(3) for the full rundown, bestie.


πŸ“ SEE ALSO πŸ“

go read those too, they're the whole friend group 🫢


heads up: this option is PLAIN-mechanism only and imap only, and the actual meaning of the authzid is server dependent β€” so don't assume, k? 😭

later bestie πŸ’– β€” this page came from the libcurl manual, dated 2026-10-12, page CURLOPT_SASL_AUTHZID(3). stay iconic ✨

πŸ“¦ where this page comes from