Hi,
I am using libcurl in c++ and been able to authenticate the user (using httpauth) so far but the main problem occurs when I try to retrieve the general document list in his\her account (using httpheader) .
here is the code for the same..!!
***************************************************************************************************************************************************
string strURL = "https://www.google.com/accounts/ClientLogin";
string strHeader = "Content-type: application/x-www-form-urlencoded";
string strPost = "POST /accounts/ClientLogin HTTP/1.0";
string strUserName = "a...@gmail.com";
string strPwd = "abc";
string strConnectionFields;
strConnectionFields = "accountType=HOSTED_OR_GOOGLE&Email=" +
strUserName + "&Passwd=" + strPwd +
"&service=writely&source=abc-abc-1";
/*Logging in the user account with the provided credentials */
curl_easy_setopt(curl,CURLOPT_URL,strURL.c_str());
curl_easy_setopt(curl,CURLOPT_POST,true);
curl_easy_setopt(curl,CURLOPT_POSTFIELDS, strConnectionFields.c_str());
curl_easy_setopt(curl,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,false); //skipping peer
verification
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, handle_data); //used to redirect
the output to function
res = curl_easy_perform(curl);
strAuthString = ReturnAuthString(strGoogleResponse);
string strHeaderString;
strHeaderString = "Authorization: GoogleLogin auth=" + strAuthString
+ " GData-Version: 3.0";
// Make the request
curl_easy_setopt(curl, CURLOPT_URL,
"http://docs.google.com/feeds/default/private/full?v=3");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, strHeaderString.c_str());
curl_easy_setopt(curl, CURLOPT_POST,false);
//curl_easy_setopt(curl,CURLOPT_VERBOSE,1); //this option is used for setting
the ouput to console by libcurl
res = curl_easy_perform(curl); // -> THE REAL PROBLEM OCCURS HERE..!!!
***************************************************************************************************************************************************
Please advise..
Thanks,
Bradd
One immediate problem is that the two headers (Authorization, and
Gdata-version) should be separated by a return character \n and not a
space character.
If there is more, can you please paste the error and the logging out
put that you got?
Regards
--
Ali Afshar | @aliafshar | Google Developer Relations
Can you get the raw request somehow, for example
http://curl.haxx.se/libcurl/c/debug.html shows how to use a callback
to get the debug information.
Regards
--
Glad you are up and running, that C++ sample would be really useful,
so thanks a lot for doing that.
Regards
--