1--- 2c: Copyright (C) Daniel Stenberg, <daniel.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) 10--- 11 12# NAME 13 14CURLOPT_XOAUTH2_BEARER - OAuth 2.0 access token 15 16# SYNOPSIS 17 18~~~c 19#include <curl/curl.h> 20 21CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XOAUTH2_BEARER, char *token); 22~~~ 23 24# DESCRIPTION 25 26Pass a char pointer as parameter, which should point to the null-terminated 27OAuth 2.0 Bearer Access Token for use with HTTP, IMAP, LDAP, POP3 and SMTP 28servers that support the OAuth 2.0 Authorization Framework. 29 30Note: For IMAP, LDAP, POP3 and SMTP, the user name used to generate the 31Bearer Token should be supplied via the CURLOPT_USERNAME(3) option. 32 33The application does not have to keep the string around after setting this 34option. 35 36# DEFAULT 37 38NULL 39 40# PROTOCOLS 41 42HTTP, IMAP, LDAP, POP3 and SMTP 43 44# EXAMPLE 45 46~~~c 47int main(void) 48{ 49 CURL *curl = curl_easy_init(); 50 if(curl) { 51 CURLcode res; 52 curl_easy_setopt(curl, CURLOPT_URL, "pop3://example.com/"); 53 curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, "1ab9cb22ba269a7"); 54 res = curl_easy_perform(curl); 55 curl_easy_cleanup(curl); 56 } 57} 58~~~ 59 60# AVAILABILITY 61 62Added in 7.33.0. Support for OpenLDAP added in 7.82.0. 63 64# RETURN VALUE 65 66Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or 67CURLE_OUT_OF_MEMORY if there was insufficient heap space. 68