#include "../curl_setup.h"
#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \
!defined(CURL_DISABLE_POP3) || \
(!defined(CURL_DISABLE_LDAP) && defined(USE_OPENLDAP))
#include <curl/curl.h>
#include "../urldata.h"
#include "vauth.h"
#include "../curlx/warnless.h"
#include "../curl_memory.h"
#include "../memdebug.h"
CURLcode Curl_auth_create_oauth_bearer_message(const char *user,
const char *host,
const long port,
const char *bearer,
struct bufref *out)
{
char *oauth;
if(port == 0 || port == 80)
oauth = curl_maprintf("n,a=%s,\1host=%s\1auth=Bearer %s\1\1", user, host,
bearer);
else
oauth = curl_maprintf("n,a=%s,\1host=%s\1port=%ld\1auth=Bearer %s\1\1",
user, host, port, bearer);
if(!oauth)
return CURLE_OUT_OF_MEMORY;
Curl_bufref_set(out, oauth, strlen(oauth), curl_free);
return CURLE_OK;
}
CURLcode Curl_auth_create_xoauth_bearer_message(const char *user,
const char *bearer,
struct bufref *out)
{
char *xoauth = curl_maprintf("user=%s\1auth=Bearer %s\1\1", user, bearer);
if(!xoauth)
return CURLE_OUT_OF_MEMORY;
Curl_bufref_set(out, xoauth, strlen(xoauth), curl_free);
return CURLE_OK;
}
#endif