Unable to retrieve access token with Application Only OAuth using Reddit API - c++

So I have read the documentation at the following link https://github.com/reddit-archive/reddit/wiki/OAuth2. I am trying to retrieve an access token for my application which only requires an Application Only OAuth since it does not require the user to insert their credentials. I have followed the instructions on the page mentioned, but I am unable to retrieve the access token and I always get:
"{\"message\": \"Unauthorized\", \"error\": 401}"
Here is my code:
#include "reddit.h"
#include <QtNetwork>
#include <QUuid>
const QString GRANT_URL = "https://oauth.reddit.com/grants/installed_client";
const QString ACCESS_TOKEN_URL = "https://www.reddit.com/api/v1/access_token";
const QByteArray CLIENT_IDENTIFIER = "MYID";
Reddit::Reddit(QObject *parent) : QObject(parent)
{
mDeviceID = "DO_NOT_TRACK_THIS_DEVICE";
mAuthHeader = "Basic " + CLIENT_IDENTIFIER.toBase64();
}
void Reddit::getAccessToken()
{
auto netManager = new QNetworkAccessManager(this);
QUrl requestUrl = buildAccessTokenUrl();
QNetworkRequest netRequest(requestUrl);
netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
netRequest.setRawHeader("Authorization", mAuthHeader);
auto reply = netManager->post(netRequest, requestUrl.query(QUrl::FullyEncoded).toUtf8());
connect(reply, &QNetworkReply::finished, this, &Reddit::accessTokenRequestFinished);
}
void Reddit::accessTokenRequestFinished()
{
auto reply = qobject_cast<QNetworkReply*>(sender());
qDebug() << reply->readAll();
reply->deleteLater();
}
QUrl Reddit::buildAccessTokenUrl()
{
QUrl url(ACCESS_TOKEN_URL);
QUrlQuery urlQuery;
urlQuery.addQueryItem("grant_type", GRANT_URL);
urlQuery.addQueryItem("device_id", mDeviceID);
url.setQuery(urlQuery);
return url;
}
I have registerd my application at https://ssl.reddit.com/prefs/apps/ using the "installed" type option.

Ok so I found the problem. I didn't read the 'Basic' HTTP Authentication Scheme and forgot a : in my authorization header which I modified to:
mAuthHeader = "Basic " + (CLIENT_IDENTIFIER + ":").toBase64();

Related

Qt Json Parsing c++

I am trying to parse json object in QT from an api. However when i try the codes written below i cannot parse the object. I simply want to get the information stored in those parameters.
API is
{
"error": {
"errorcode": 0,
"errorstring": ""
},
"login": 1,
"logintoken": "209b06aa7f059673db393ff7a731af1847344903b9733f026cc3a6f7a5b797b3"
}
The Codes are
QUrl ava_url("http://pinundpin.de/wsdemo/atgdemoapi_v3/index.php");
QNetworkRequest ava_request(ava_url);
ava_request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
QNetworkAccessManager *manager = new QNetworkAccessManager();
QEventLoop loop;
QObject::connect(manager,
SIGNAL(finished(QNetworkReply *)),
&loop,
SLOT(quit()));
QByteArray postData;
Username = "testwebser";
Passwd = "2017#QWEasdZXC";
postData.append("action=login&");
postData.append("password="+Passwd+"&");
postData.append("username="+Username);
QNetworkReply* reply = manager->post(ava_request,postData);
loop.exec();
QString response = (QString)reply->readAll();
qDebug()<< response;
QJsonDocument temp = QJsonDocument::fromJson(response.toUtf8());
QJsonObject jsonObj = temp.object();
qDebug() <<"error"<< jsonObj["error"].toString();
qDebug() <<"login"<< jsonObj["login"].toString();
qDebug() << "logintoken"<<jsonObj["logintoken"].toString();
the response string looks
and the output is
D/libAndroisShop.so(21944): ../AndroisShop/networkconnection.cpp:45 (QString NetworkConnection::Connect(QString, QString)): "<br><br>NO OF ROWDATA: 1{\"error\":{\"errorcode\":0,\"errorstring\":\"\"},\"login\":1,\"logintoken\":\"4daaf6b3dd5a26a2ad2c436e564bfa4d6c439ce4d0d6cd66705a8bdadddddaa0\"}"
D/libAndroisShop.so(21944): ../AndroisShop/networkconnection.cpp:50 (QString NetworkConnection::Connect(QString, QString)): error ""
D/libAndroisShop.so(21944): ../AndroisShop/networkconnection.cpp:51 (QString NetworkConnection::Connect(QString, QString)): login ""
D/libAndroisShop.so(21944): ../AndroisShop/networkconnection.cpp:52 (QString NetworkConnection::Connect(QString, QString)): logintoken ""
Postman Image
If you review the result of POSTMAN in raw mode you get the following:
What QNAM gets but POSTMAN has another algorithm to extract the json:
So a possible solution is to remove the unwanted element: <br><br>NO OF ROWDATA: 1, for this it takes advantage that the json must start with "{" so the superior substring is used.
QUrl ava_url("http://pinundpin.de/wsdemo/atgdemoapi_v3/index.php");
QNetworkRequest ava_request(ava_url);
ava_request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
QNetworkAccessManager *manager = new QNetworkAccessManager();
QEventLoop loop;
QObject::connect(manager,
&QNetworkAccessManager::finished,
&loop,
&QEventLoop::quit);
QByteArray postData;
QString Username = "testwebser";
QString Passwd = "2017#QWEasdZXC";
postData.append("action=login&");
postData.append("password="+Passwd+"&");
postData.append("username="+Username);
QNetworkReply *reply = manager->post(ava_request,postData);
loop.exec();
QByteArray response = reply->readAll();
QByteArray json = response.mid(response.indexOf("{"));
QJsonDocument temp = QJsonDocument::fromJson(json);
QJsonObject jsonObj = temp.object();
QJsonObject errorObj = jsonObj["error"].toObject();
qDebug()<<"error: "
<<"errorcode: "<< errorObj["errorcode"].toInt()
<<"errorstring: "<< errorObj["errorstring"].toString();
qDebug() <<"login"<< jsonObj["login"].toInt();
qDebug() << "logintoken"<<jsonObj["logintoken"].toString();
Output:
error: errorcode: 0 errorstring: ""
login 1
logintoken "cc7e46f34e0a268cecbaaeaad41b0ae2727cc7196b632574a4db16544576d012"

How to set redirect_uri using QOAuth2AuthorizationCodeFlow and QOAuthHttpServerReplyHandler

For OAuth 2.0 using QT's networkauth and the new QOAuth2AuthorizationCodeFlow object, how can I set the redirect_uri? My code is below. It results in the following authenticate url being sent:
QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl: https://accounts.google.com/o/oauth2/auth?client_id=123-abc.apps.googleusercontent.com&redirect_uri=http://localhost:65535/cb&response_type=code&scope=email&state=iEIYn5sN
The setting of redirect_uri to "http://localhost", results in an Error 400 redirect_uri_mismatch from google which is obviously expecting the actual redirect hostname to be provided.
GoogleGateway::GoogleGateway() {
auto google = new QOAuth2AuthorizationCodeFlow;
google->setScope("email");
this->connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::openUrl);
QString val;
QFile file;
file.setFileName("/home/me/client_secret.json");
file.open(QIODevice::ReadOnly | QIODevice::Text);
val = file.readAll();
file.close();
QJsonDocument document = QJsonDocument::fromJson(val.toUtf8());
QJsonObject object = document.object();
const auto settingsObject = object["web"].toObject();
const QUrl authUri(settingsObject["auth_uri"].toString());
const auto clientId = settingsObject["client_id"].toString();
const QUrl tokenUri(settingsObject["token_uri"].toString());
const auto clientSecret(settingsObject["client_secret"].toString());
const auto redirectUris = settingsObject["redirect_uris"].toArray();
const QUrl redirectUri(redirectUris[0].toString());
const auto port = static_cast<quint16>(redirectUri.port());
google->setAuthorizationUrl(authUri);
google->setClientIdentifier(clientId);
google->setAccessTokenUrl(tokenUri);
google->setClientIdentifierSharedKey(clientSecret);
auto replyHandler = new QOAuthHttpServerReplyHandler(port, this);
google->setReplyHandler(replyHandler);
google->grant();
}
To set the redirect_uri, I've tried replacing:
auto replyHandler = new QOAuthHttpServerReplyHandler(port, this);
with
QHostAddress hostaddress = QHostAddress(quint32(1233...));
auto replyHandler = new QOAuthHttpServerReplyHandler(hostaddress, port, this);
with no change in the result.
Have also tried inserting:
replyHandler->setProperty("redirect_uri", "http://abc.xyz.com:65535/cb");
also with no change in the result.
In Qt/5.8/Src/qtnetworkauth/src/oauth/qoauthhttpserverreplyhandler.cpp, we see that the callback address looks suspiciously hard-coded:
QString QOAuthHttpServerReplyHandler::callback() const
{
Q_D(const QOAuthHttpServerReplyHandler);
Q_ASSERT(d->httpServer.isListening());
const QUrl url(QString::fromLatin1("http://localhost:%1/cb").arg(d->httpServer.serverPort()));
return url.toString(QUrl::EncodeDelimiters);
}
This callback() is in turn used in Qt/5.8/Src/qtnetworkauth/src/oauth/qoauth2authorizationcodeflow.cpp to set the redirectUri value:
QUrl QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl(const QVariantMap &parameters)
{
Q_D(QOAuth2AuthorizationCodeFlow);
using Key = QAbstractOAuth2Private::OAuth2KeyString;
if (d->state.isEmpty())
setState(QAbstractOAuth2Private::generateRandomState());
Q_ASSERT(!d->state.isEmpty());
const QString state = d->state;
QVariantMap p(parameters);
QUrl url(d->authorizationUrl);
p.insert(Key::responseType, responseType());
p.insert(Key::clientIdentifier, d->clientCredentials.first);
p.insert(Key::redirectUri, callback());
p.insert(Key::scope, d->scope);
p.insert(Key::state, state);
if (d->modifyParametersFunction)
d->modifyParametersFunction(Stage::RequestingAuthorization, &p);
url.setQuery(d->createQuery(p));
connect(d->replyHandler.data(), &QAbstractOAuthReplyHandler::callbackReceived, this,
&QOAuth2AuthorizationCodeFlow::authorizationCallbackReceived, Qt::UniqueConnection);
setStatus(QAbstractOAuth::Status::NotAuthenticated);
qDebug("QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl: %s", qPrintable(url.toString()));
return url;
}
Is this a bug?
I just solved this by subclassing MyOAuthHttpServerReplyHandler and overriding the definition of callback() to return the URI I wanted.
I'm using Qt 5.15, the redirect_uri could be change form QAbstractOAuth::modifyParametersFunction
m_google = new QOAuth2AuthorizationCodeFlow(m_manager,this);
// set other parameters...
m_google->setModifyParametersFunction(buildModifyParametersFunction());
// return ModifyParametersFunction()
QAbstractOAuth::ModifyParametersFunction GoogleOAuth2Wrapper::buildModifyParametersFunction()
{
const QUrl clientIdentifier = m_google->clientIdentifier();
const QUrl clientIdentifierSharedKey = m_google->clientIdentifierSharedKey();
return [clientIdentifier,clientIdentifierSharedKey]
(QAbstractOAuth::Stage stage, QVariantMap *parameters){
if(stage == QAbstractOAuth::Stage::RequestingAuthorization){
parameters->insert("redirect_uri","https://127.0.0.1:8080/cb"); /*change redirect uri*/
}
};
}
QOAuth2AuthorizationCodeFlow class use QUrl buildAuthenticateUrl(const QVariantMap &parameters) method to send browser for access token,here's source:
QUrl QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl(const QVariantMap &parameters)
{
Q_D(QOAuth2AuthorizationCodeFlow);
using Key = QAbstractOAuth2Private::OAuth2KeyString;
if (d->state.isEmpty())
setState(QAbstractOAuth2Private::generateRandomState());
Q_ASSERT(!d->state.isEmpty());
const QString state = d->state;
QVariantMap p(parameters);
QUrl url(d->authorizationUrl);
p.insert(Key::responseType, responseType());
p.insert(Key::clientIdentifier, d->clientIdentifier);
p.insert(Key::redirectUri, callback());
p.insert(Key::scope, d->scope);
p.insert(Key::state, state);
if (d->modifyParametersFunction) /** Here's what we take part **/
d->modifyParametersFunction(Stage::RequestingAuthorization, &p);
url.setQuery(d->createQuery(p));
connect(d->replyHandler.data(), &QAbstractOAuthReplyHandler::callbackReceived, this,
&QOAuth2AuthorizationCodeFlow::authorizationCallbackReceived, Qt::UniqueConnection);
setStatus(QAbstractOAuth::Status::NotAuthenticated);
qCDebug(d->loggingCategory, "Generated URL: %s", qPrintable(url.toString()));
return url;
}
I hope that is helpful.
Reference
QAbstractOAuth::modifyParametersFunction
QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl source
Using Qt 5.15, having your redirect URI overridden is no longer a problem, but there are two others that you might be running into:
If you use the first URL provided in Google's credential JSON, your app might not hearing back from the user's browser at the end of authorization flow. Instead, just use http://127.0.0.1:1234/ which is reliably the user's machine.
Depending on your luck, the login code returned by Google is URL-encoded and it may contain characters that need to be URL-decoded before requesting a login token from Google itself. This is something that I'd expect Qt to take care of for you, but instead you have to inject a parameter modifier.
Here is the key block, taken from our post on authenticating a Qt app with Google SSO:
this->google->setModifyParametersFunction([](QAbstractOAuth::Stage stage, QVariantMap* parameters) {
// Percent-decode the "code" parameter so Google can match it
if (stage == QAbstractOAuth::Stage::RequestingAccessToken) {
QByteArray code = parameters->value("code").toByteArray();
(*parameters)["code"] = QUrl::fromPercentEncoding(code);
}
});

Error during multipart upload using Qt

I am trying to upload a file using QNetworkAccessManager, but I always get an error (Error transferring url - server replied: Bad Request). Below is my code
QString name = "Simple.txt";
QString type = "text/plain; charset=utf-8";
QString uploadUrl = "myuploadUrl";
// setup the multipart request
QString bound="---------------------------723690991551375881941828858";
QByteArray data(QString("--"+bound+"\r\n").toLatin1());
// write the file using standard method for multipart file upload
data += "Content-Disposition: form-data; name=\"file\"; filename=\""+name.toLatin1()+"\"\r\n";
data += "Content-Type: "+type.toLatin1()+"\r\n\r\n";
data += "Hello, I am simple file";
data += "\r\n";
data += "--" + bound;
qDebug() << data;
// make the request with appropriate headers
QNetworkRequest request(QUrl(uploadUrl));
request.setRawHeader(QByteArray("Content-Type"),QString("multipart/form-data; boundary=" + bound).toLatin1());
request.setRawHeader(QByteArray("Content-Length"), QString::number(data.length()).toLatin1());
QNetworkReply *reply = networkManager->post(request,data);
QObject::connect(reply, &QNetworkReply::finished, this, FileUploader::requestFinished);
However running this python script, which should do the same thing, works.
import requests
import json
file_name = "Simple.txt"
uploadUrl = "myUploadUrl";
resp = requests.post(uploadUrl, data=r["data"], files={"file": open(file_name, "rb")})
print (resp);
The problem was fixed by adding a data += "\r\n" at the end of the data.
Instead of creating request manually use QT internals. Here You can try this code which is working for me.
void OfflineLogHandler::uploadOfflineLogFile(QString filePath){
QUrl targateUlr(APIUrls::getInstance()->getFlightLogUploadURL()); //pass URL here
APIUrls *apiUrls = APIUrls::getInstance();
qDebug()<<"Target upload offline log url:"<<targateUlr;
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
QHttpPart formHeader;
formHeader.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"\"; filename=\""+filePath.section("/",-1)+"\""));
if(filePath.contains(".json"))
formHeader.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
else if(filePath.contains(".csv"))
formHeader.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/csv"));
QFile *file = new QFile(filePath);
file->open(QIODevice::ReadOnly);
formHeader.setBodyDevice(file);
multiPart->append(formHeader);
file->setParent(multiPart);
QNetworkRequest request;
request.setUrl(targateUlr);
QString CredData = apiUrls->getCredentials();
QString headerData = apiUrls->getApiAuthorizationType() + CredData;
qDebug()<<"access:"<<headerData.toLocal8Bit();
request.setRawHeader( "Authorization", headerData.toLocal8Bit() );
request.setRawHeader("CustomeData1","Data1");
request.setRawHeader("CustomeData2","Data2");
request.setHeader(QNetworkRequest::ContentTypeHeader,QString("multipart/form-data; boundary="+multiPart->boundary()).toLatin1());
QNetworkAccessManager *restclient; //in class
restclient = new QNetworkAccessManager(); //constructor
disconnect(restclient,SIGNAL(finished(QNetworkReply*)), this, nullptr);
connect(restclient, SIGNAL(finished(QNetworkReply*)), this, SLOT(handleFileUploadResponse(QNetworkReply*)));
networkReply = restclient->post(request,multiPart);
connect(networkReply,SIGNAL(uploadProgress(qint64, qint64)),this,SLOT(fileUprogress(qint64, qint64)));
qDebug()<<"net:"<<networkReply;
}

How to intercept AJAX-Requests within QtWebKit?

I want to intercept, inspect and (if needed) reject AJAX-Requests based on the Fingerprint of the SSL-Certificate. I use the QNetworkAccessManager::createRequest(...) function to issue requests. Everything works fine when I use QWebFrame::load(...). Even the content which is loaded within the request (like .css or .js files) emit signals. Unfortunately no AJAX-Requests emits any Signals. I know that the Signals are connected to the very same slots (for "normal" as well as AJAX-Requests) within MyNetworkAccessManager::createRequest(...) function.
QNetworkReply *reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
connect(reply, SIGNAL(readyRead()), this, SLOT(handleStarted()));
connect(reply, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(handleSslErrors(const QList<QSslError> &)));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(handleNetworkError()));
Why are AJAX Requests so different? Where can I access them?
From what I can tell, AJAX requests do emit the finished signal on QNetworkAccessManager. You need connect to the instance of QNetworkAccessManager on your QWebPage instance:
QWebPage *page = ui->webView->page();
QNetworkAccessManager *nam = page->networkAccessManager();
connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
QFile file;
file.setFileName(":/js/jquery-2.1.1.min.js"); // jQuery is loaded as a resource
file.open(QIODevice::ReadOnly);
QString jQuery = file.readAll();
file.close();
ui->webView->load(QUrl("about:blank"));
QWebFrame *frame = m_page->mainFrame();
frame->evaluateJavaScript(jQuery); // load jQuery
// check that jQuery is loaded
frame->evaluateJavaScript("$(document).ready(function() { alert('jQuery loaded!'); });");
// do an AJAX GET
frame->evaluateJavaScript("$.ajax({"
"url: 'http://www.json-generator.com/api/json/get/cqkXBAEoQy?indent=2',"
"method: 'GET',"
"dataType: 'json'"
"}).done(function (data) {"
"for (var i = 0; i < data.length; i++) {"
"alert(data[i].name);"
"}"
"}).error(function (data) { alert('AJAX error'); });");
Then you can monitor replies in the replyFinished slot like so:
void MainWindow::replyFinished(QNetworkReply *reply)
{
QByteArray bytes = reply->readAll();
QString str = QString::fromUtf8(bytes.data(), bytes.size());
QString replyUrl = reply->url().toString();
int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
qDebug() << statusCode;
qDebug() << replyUrl;
qDebug() << str;
}
I have noticed that jQuery AJAX's done promise doesn't seem to execute when you do anything with the QNetworkReply, but you can see that the request actually finishes in the debug console.
See my GitHub repository to try out the above code: https://github.com/pcmantinker/QtWebkitAJAX
As far as blocking connections based on SSL certificates, you'd have to subclass QNetworkAccessManager and override QNetworkAccessManager::createRequest. Something like this could work:
QNetworkReply *CustomQNetworkAccessManager::createRequest(Operation op, const QNetworkRequest& request, QIODevice* outgoingData)
{
QNetworkRequest req(request);
QNetworkReply *reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
QSslConfiguration *sslConfig = reply->sslConfiguration();
QList<QSslCertificate> sslCaCerts = sslConfig->caCertificates();
// do something with sslCaCerts
return reply;
}

Login to website using Qt

I need to login to a website to retrieve the source code of a page. How would I do this using Qt?
I'm not familiar with how QUrl and QNetworkAcessManager work, but I was able to write code that would allow me to download the source code for any page not behind a login form.
This is what I have so far. I end up just downloading the source for the redirect page:
test = new QNetworkAccessManager(this);
QUrl URL = QUrl("http://website.com/page");
URL.setUserName("user");
URL.setPassword("password");
test->get(QNetworkRequest(URL));
Edit:
QByteArray loginData("username=user&password=password");
QNetworkRequest request(QUrl("http://website.com/login/index.php"));
manager->post(request,loginData);
QUrl URL = QUrl("http://website.com/mod/resource/view.php?id=114198");
manager->get(QNetworkRequest(URL));
I am still retrieving a 303 reply.
The page is on Moodle, which uses a HTTP POST login form.
I've also tried with a different site. POST works but I get the source code of the login page with the login form filled out. Not sure how to get the page after logging in.
This was my solution, for logging into a particular website and retrieving a file. I was getting redirected multiple times before reaching the destination. I test HTTP status codes until I get the final reply. I also test to see if the final URL is the one I requested and not some home page behind the login page. This is because I am downloading a file.
QByteArray loginData;
loginData.append("username="+(ui->lineEdit_2->text())+"&password="+(ui->lineEdit_3->text())+"&action=login");
cookiesHandler* test = new cookiesHandler(this);
QUrl request("http://website.com");
test->sendPostRequest(request, loginData);
Cookies Handler Class
class cookiesHandler: public QObject{
Q_OBJECT
public:
cookiesHandler(QObject *parent = 0) : QObject(parent){
mManager = new QNetworkAccessManager(this);
mManager->setCookieJar(new QNetworkCookieJar(this));
connect(mManager, SIGNAL(finished(QNetworkReply*)), SLOT(replyFinished(QNetworkReply*)));
}
void sendPostRequest(const QUrl &url, const QByteArray &data){
mUrl = url;
login = data;
QNetworkRequest r(mUrl);
mManager->post(r, data);
}
void sendGetRequest(const QUrl &url)
{
mUrl = url;
test = mUrl;
QNetworkRequest r(mUrl);
mManager->get(r);
}
virtual ~cookiesHandler(){}
private slots:
void replyFinished(QNetworkReply *reply){
if (reply->error() != QNetworkReply::NoError){
qWarning() << "ERROR:" << reply->errorString();
return;
}
//Cookies//
QList<QNetworkCookie> cookies = mManager->cookieJar()->cookiesForUrl(mUrl);
qDebug() << "COOKIES for" << mUrl.host() << cookies;
QString str;
QDebug dStream(&str);
dStream << mUrl.host() << cookies;
//End Cookies//
int v = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (v >= 200 && v < 300) // Success
{
getFile(reply);
// Here we got the final reply
return;
}
else if (v >= 300 && v < 400) // Redirection
{
/* Use Cookies for Login */
qDebug() << "REDIRECTING";
rUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
if(rUrl != mUrl)
{
mManager->post(QNetworkRequest(rUrl),login);
return;}
out << QString("redirected: " + rUrl.toEncoded()) << endl;
QNetworkRequest r(mUrl);
QVariant var;
var.setValue(cookies);
r.setHeader(QNetworkRequest::CookieHeader, var);
mManager->get(r);
return;
}
}