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