CURLOPT_XOAUTH2_BEARER(3)
π CURLOPT_XOAUTH2_BEARER(3) π
okay so bestie, this is a libcurl page from the Library Functions Manual, and it's all about the OAuth 2.0 access token option. pull up a chair, we're gonna make it make sense. β¨
πΈ NAME πΈ
CURLOPT_XOAUTH2_BEARER β OAuth 2.0 access token
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XOAUTH2_BEARER, char *token);
π¦ DESCRIPTION π¦
okay so you pass a char pointer as the parameter, and that pointer should point to the null-terminated OAuth 2.0 Bearer Access Token. it's for use with HTTP, IMAP, LDAP, POP3 and SMTP servers that support the OAuth 2.0 Authorization Framework. π
note, bestie: for IMAP, LDAP, POP3 and SMTP, the username used to generate the Bearer Token should be supplied via the CURLOPT_USERNAME(3) option. iykyk. π«Ά
the application does not have to keep the string around after setting this option. so no need to clutch it forever. π
using this option multiple times makes the last set string override the previous ones. set it to NULL to disable its use again. fr fr. π₯
π DEFAULT π
NULL β that's the default, no token, no problem. periodt. π
π PROTOCOLS π
This functionality affects http, imap, ldap, pop3 and smtp. that's the whole vibe check, no gatekeeping. β¨
π EXAMPLE π
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "pop3://example.com/");
curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, "1ab9cb22bf269a7");
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
π§ HISTORY π§
Support for OpenLDAP added in 7.82.0. slay, OpenLDAP got her moment. π
β AVAILABILITY β
Added in curl 7.33.0. she's been around, and she's iconic. π
π₯ RETURN VALUE π₯
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). so yeah, zero is the good vibe, non-zero is your cue to go read the errors page. π
π«Ά SEE ALSO π«Ά
go read these next, bestie. they're literally right there. π
xoxo, source/version libcurl π β dated 2026-10-12, and yes bestie this is the CURLOPT_XOAUTH2_BEARER(3) page. mwah! π
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms