我正在使用Windovs的C++编写应用程序以使用云服务Amazon。我需要在网站上获得授权才能使用特定数据,并且我想获得Access令牌。问题是我想要的,我没有使用浏览器获得授权,但我不明白如何。我使用卷曲的项目,并发送类似如下的要求:当我得到响应我有一个HTML页面的授权文件的副本在没有浏览器的情况下登录亚马逊
int main(void) {
CURL *curl;
CURLcode res;
struct curl_slist *list = NULL;
FILE *Response = fopen("Response.txt", "wb+");
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://www.amazon.com/ap/oa?client_id=%MY CLIENT ID%scope=clouddrive:read_all&response_type=token&redirect_uri=http://localhost");
list = curl_slist_append(list, "Accept: text/html");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, SaveData);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, Response);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK)
fprintf(Response, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
curl_slist_free_all(list);
/* always cleanup */
curl_easy_cleanup(curl);
}
。/下面是答案的一部分/
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<script type='text/javascript'>var ue_t0=ue_t0||+new Date();</script>
<script type='text/javascript'>
var ue_csm = window,
ue_hob = +new Date();
如果我不能使用的浏览器,而我可以用Web浏览器(无边框)打开一个小窗口,并接收来自服务器的数据(访问令牌)。文档中没有任何内容(Amazon文档)。