Gavin,
Example of usage:
#include <curl/curl.h>
#include <string>
#include "curl/curlcategory.hpp"
using std::string;
Bearer::Bearer(string token) :
m_token(token)
{}
const char* Bearer::get_Token() const noexcept
{
return m_token.c_str();
}
void Bearer::Authenticate(CURL* pCurl) const
{
CURLcode c = CURLE_OK;
std::cerr << "Warning: memory set with CURLOPT_XOAUTH2_BEARER is known to
leak." << std::endl;
// This libcurl code works, but leaks the bearer token.
// https://github.com/curl/curl/issues/8841
c = curl_easy_setopt(pCurl, CURLOPT_HTTPAUTH, CURLAUTH_BEARER);
if (CURLE_OK != c)
throw std::system_error(c, curl_category());
c = curl_easy_setopt(pCurl, CURLOPT_XOAUTH2_BEARER, getToken());
if (CURLE_OK != c)
throw std::system_error(c, curl_category());
}
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
From: Gavin Henry via curl-library<mailto:[email protected]>
Sent: Monday, February 20, 2023 6:46 PM
To: libcurl development<mailto:[email protected]>
Cc: Gavin Henry<mailto:[email protected]>
Subject: Re: CURLOPT_XOAUTH2_BEARER use?
In the absence of your code listing and lack of additional info, I can only try
to guess...
- Protocol is http(s)
. You do not set CURLOPT_HTTPAUTH
(https://curl.se/libcurl/c/CURLOPT_HTTPAUTH.html). This is probably what you
need.
Thanks! I did my first version today, but this will simplify things :)
Gavin.
--
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html