PDA

View Full Version : Fail use QNetworkAccessManager to implement goole account login



kellen851105
1st April 2010, 01:29
Hi, I did a demo using QNetworkAccessManager to post a request to google account authentication url
https://www.google.com/accounts/ClientLogin
with my email and password .etc as request body, but I always got the reply status code 0,normally the satus
code is 200

The parameter used in authentication is located at
http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html


The practice is more or less like this,

QNetworkRequest* request = new QNetworkRequest(QUrl("https://www.google.com/accounts/ClientLogin"));
QByteArray content = "EMAIL=***&Passwd=***&service=cl&source=***&accountType=***";
request->setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
networkAccessManager->post(*request, content);


and In onFinished(QNetworkReply* reply) slot, I get reply status code by
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute ).toInt();

The status code of reply is always 0. I don't know why, normally the status code should be 200. and if I modify the https to http, the reply status code turn to 302 means redirection, this seems correct.

kellen851105
1st April 2010, 15:20
Somebody help me, thanks a lot.