summaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorKyle L. Huff <kyle.huff@curetheitch.com>2013-08-25 13:17:20 -0400
committerSteve Holme <steve_holme@hotmail.com>2013-08-25 22:03:57 +0100
commit06c1bea72faabb6fad4b7ef818aafaa336c9a7aa (patch)
tree11f12873c373e217c2a5948bd1df49ee07288501 /lib/url.c
parent19a05c908f7d8be82de6f69f533317d8a0db49dd (diff)
downloadcurl-06c1bea72faabb6fad4b7ef818aafaa336c9a7aa.tar.gz
options: added basic SASL XOAUTH2 support
Added the ability to specify an XOAUTH2 bearer token [RFC6750] via the option CURLOPT_XOAUTH2_BEARER for authentication using RFC6749 "OAuth 2.0 Authorization Framework".
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/url.c b/lib/url.c
index 5057018c5..2f72bc146 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1569,6 +1569,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
result = setstropt(&data->set.str[STRING_PASSWORD],
va_arg(param, char *));
break;
+ case CURLOPT_XOAUTH2_BEARER:
+ /*
+ * XOAUTH2 bearer token to use in the operation
+ */
+ result = setstropt(&data->set.str[STRING_BEARER],
+ va_arg(param, char *));
+ break;
case CURLOPT_POSTQUOTE:
/*
* List of RAW FTP commands to use after a transfer
@@ -2488,6 +2495,7 @@ static void conn_free(struct connectdata *conn)
Curl_safefree(conn->user);
Curl_safefree(conn->passwd);
+ Curl_safefree(conn->xoauth2_bearer);
Curl_safefree(conn->options);
Curl_safefree(conn->proxyuser);
Curl_safefree(conn->proxypasswd);
@@ -5181,6 +5189,13 @@ static CURLcode create_conn(struct SessionHandle *data,
}
}
+ if(data->set.str[STRING_BEARER]) {
+ conn->xoauth2_bearer = strdup(data->set.str[STRING_BEARER]);
+ if(!conn->xoauth2_bearer) {
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+
#ifndef CURL_DISABLE_PROXY
/*************************************************************
* Extract the user and password from the authentication string