Код: Выделить всё
struct CurlResponse
{
CURLcode response_code = CURLE_OK;
std::string body;
std::string headers;
};
const std::string url_imaps = "imaps://imap.gmail.com:993";
curl_easy_setopt(curl, CURLOPT_URL, url_imaps.c_str());
std::string oauth_token = "user=" + email + "\1auth=Bearer " + password + "\1\1";
std::string base64_token = encode_base64(oauth_token);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, base64_token);
//Due to lack of certificate, we disable verification
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, CURL_FALSE);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, CURL_FALSE);
CurlResponse response;
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&response.body);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, (void*)&response.headers);
response.response_code = curl_easy_perform(curl);
Подробнее здесь: https://stackoverflow.com/questions/786 ... cess-token