GNURLOPT_XOAUTH2_BEARER(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_XOAUTH2_BEARER(3) β€” the curl_easy_setopt girlies' era

okay so bestie, this page lives in the curl_easy_setopt options section of the gnurl manual, and it's genuinely one of the more iconic ones. buckle up πŸŽ€


✨ NAME ✨

CURLOPT_XOAUTH2_BEARER β€” specify OAuth 2.0 access token πŸ¦‹

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XOAUTH2_BEARER, char *token);

✨ DESCRIPTION ✨

so you pass a char * as the parameter, and that pointer should point at a null-terminated OAuth 2.0 Bearer Access Token. literally just hand over the token and let it vibe. it's for use with HTTP, IMAP, POP3 and SMTP servers that support the OAuth 2.0 Authorization Framework ✨

🫢 note note note: for IMAP, POP3 and SMTP, the user name used to generate the Bearer Token should be supplied via the CURLOPT_USERNAME(3) option. like, that's the pairing, iykyk πŸ’…

and the best part? the application does not have to keep the string around after setting this option. you can let it go, no strings attached, main character energy 😌

✨ DEFAULT ✨

NULL πŸ’€ (as in, nothing, nada, no token yet)

✨ PROTOCOLS ✨

IMAP, POP3 and SMTP 🌸

✨ EXAMPLE ✨

ok so here's the whole little situation, copy it exactly bestie:

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "pop3://example.com/");
  curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, "1ab9cb22ba269a7");
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

ate, no crumbs πŸ”₯

✨ AVAILABILITY ✨

Added in 7.33.0 ⭐ (so if you're on something ancient, that's a you problem, upgrade bb)

✨ RETURN VALUE ✨

returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space 😭 (heap space said "not today")

✨ SEE ALSO ✨


and that's the page, bestie πŸ§šπŸ’– this one shipped as part of libcurl 7.37.0, dated 19 Jun 2014, and it's filed under GNURLOPT_XOAUTH2_BEARER(3) β€” slay, go get that token πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from