CURLOPT_XOAUTH2_BEARER.md (1636B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_XOAUTH2_BEARER 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_MAIL_AUTH (3) 9 - CURLOPT_USERNAME (3) 10 Protocol: 11 - HTTP 12 - IMAP 13 - LDAP 14 - POP3 15 - SMTP 16 Added-in: 7.33.0 17 --- 18 19 # NAME 20 21 CURLOPT_XOAUTH2_BEARER - OAuth 2.0 access token 22 23 # SYNOPSIS 24 25 ~~~c 26 #include <curl/curl.h> 27 28 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XOAUTH2_BEARER, char *token); 29 ~~~ 30 31 # DESCRIPTION 32 33 Pass a char pointer as parameter, which should point to the null-terminated 34 OAuth 2.0 Bearer Access Token for use with HTTP, IMAP, LDAP, POP3 and SMTP 35 servers that support the OAuth 2.0 Authorization Framework. 36 37 Note: For IMAP, LDAP, POP3 and SMTP, the username used to generate the Bearer 38 Token should be supplied via the CURLOPT_USERNAME(3) option. 39 40 The application does not have to keep the string around after setting this 41 option. 42 43 Using this option multiple times makes the last set string override the 44 previous ones. Set it to NULL to disable its use again. 45 46 # DEFAULT 47 48 NULL 49 50 # %PROTOCOLS% 51 52 # EXAMPLE 53 54 ~~~c 55 int 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 70 Support for OpenLDAP added in 7.82.0. 71 72 # %AVAILABILITY% 73 74 # RETURN VALUE 75 76 curl_easy_setopt(3) returns a CURLcode indicating success or error. 77 78 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 79 libcurl-errors(3).