1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #include "curl_setup.h"
- #include <curl/curl.h>
- #include "urldata.h"
- #include "vauth/vauth.h"
- #include "curl_base64.h"
- #include "warnless.h"
- #include "curl_printf.h"
- #include "curl_memory.h"
- #include "memdebug.h"
- CURLcode Curl_auth_create_oauth_bearer_message(struct Curl_easy *data,
- const char *user,
- const char *host,
- const long port,
- const char *bearer,
- char **outptr, size_t *outlen)
- {
- CURLcode result = CURLE_OK;
- char *oauth = NULL;
-
- if(host == NULL && (port == 0 || port == 80))
- oauth = aprintf("user=%s\1auth=Bearer %s\1\1", user, bearer);
- else if(port == 0 || port == 80)
- oauth = aprintf("user=%s\1host=%s\1auth=Bearer %s\1\1", user, host,
- bearer);
- else
- oauth = aprintf("user=%s\1host=%s\1port=%ld\1auth=Bearer %s\1\1", user,
- host, port, bearer);
- if(!oauth)
- return CURLE_OUT_OF_MEMORY;
-
- result = Curl_base64_encode(data, oauth, strlen(oauth), outptr, outlen);
- free(oauth);
- return result;
- }
|