1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_XOAUTH2_BEARER 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_MAIL_AUTH (3) 9 - CURLOPT_USERNAME (3) 10Protocol: 11 - HTTP 12 - IMAP 13 - LDAP 14 - POP3 15 - SMTP 16Added-in: 7.33.0 17--- 18 19# NAME 20 21CURLOPT_XOAUTH2_BEARER - OAuth 2.0 access token 22 23# SYNOPSIS 24 25~~~c 26#include <curl/curl.h> 27 28CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XOAUTH2_BEARER, char *token); 29~~~ 30 31# DESCRIPTION 32 33Pass a char pointer as parameter, which should point to the null-terminated 34OAuth 2.0 Bearer Access Token for use with HTTP, IMAP, LDAP, POP3 and SMTP 35servers that support the OAuth 2.0 Authorization Framework. 36 37Note: For IMAP, LDAP, POP3 and SMTP, the username used to generate the Bearer 38Token should be supplied via the CURLOPT_USERNAME(3) option. 39 40The application does not have to keep the string around after setting this 41option. 42 43Using this option multiple times makes the last set string override the 44previous ones. Set it to NULL to disable its use again. 45 46# DEFAULT 47 48NULL 49 50# %PROTOCOLS% 51 52# EXAMPLE 53 54~~~c 55int main(void) 56{ 57 CURL *curl = curl_easy_init(); 58 if(curl) { 59 CURLcode res; 60 curl_easy_setopt(curl, CURLOPT_URL, "pop3://example.com/"); 61 curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, "1ab9cb22ba269a7"); 62 res = curl_easy_perform(curl); 63 curl_easy_cleanup(curl); 64 } 65} 66~~~ 67 68# HISTORY 69 70Support for OpenLDAP added in 7.82.0. 71 72# %AVAILABILITY% 73 74# RETURN VALUE 75 76Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or 77CURLE_OUT_OF_MEMORY if there was insufficient heap space. 78