updated for dropbpox support, need to rework these commits though
This commit is contained in:
parent
c8d1a2d66c
commit
c3fc131c22
1 changed files with 23 additions and 1 deletions
|
@ -305,6 +305,12 @@ void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) {
|
||||||
networkRequest.setRawHeader("Authorization", authHeader);
|
networkRequest.setRawHeader("Authorization", authHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(request->oauthMethod() == KQOAuthRequest::OAUTH2) {
|
||||||
|
QByteArray bearer;
|
||||||
|
bearer.append(request->additionalParameters().value("oauth_token"));
|
||||||
|
networkRequest.setRawHeader("Authorization", "Bearer " + bearer);
|
||||||
|
qDebug() << networkRequest.rawHeader("Authorization");
|
||||||
|
}
|
||||||
|
|
||||||
disconnect(d->networkManager, SIGNAL(finished(QNetworkReply *)),
|
disconnect(d->networkManager, SIGNAL(finished(QNetworkReply *)),
|
||||||
this, SLOT(onRequestReplyReceived(QNetworkReply *)));
|
this, SLOT(onRequestReplyReceived(QNetworkReply *)));
|
||||||
|
@ -312,8 +318,14 @@ void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) {
|
||||||
this, SLOT(onAuthorizedRequestReplyReceived(QNetworkReply*)), Qt::UniqueConnection);
|
this, SLOT(onAuthorizedRequestReplyReceived(QNetworkReply*)), Qt::UniqueConnection);
|
||||||
|
|
||||||
if (request->httpMethod() == KQOAuthRequest::GET) {
|
if (request->httpMethod() == KQOAuthRequest::GET) {
|
||||||
|
// Pull the oauth_token parameter because Dropbox
|
||||||
|
KQOAuthParameters adtlparams = request->additionalParameters();
|
||||||
|
adtlparams.remove("oauth_token");
|
||||||
|
qDebug() << adtlparams;
|
||||||
|
|
||||||
// Get the requested additional params as a list of pairs we can give QUrl
|
// Get the requested additional params as a list of pairs we can give QUrl
|
||||||
QList< QPair<QString, QString> > urlParams = d->createQueryParams(request->additionalParameters());
|
// QList< QPair<QString, QString> > urlParams = d->createQueryParams(request->additionalParameters());
|
||||||
|
QList< QPair<QString, QString> > urlParams = d->createQueryParams(adtlparams);
|
||||||
|
|
||||||
// Take the original URL and append the query params to it.
|
// Take the original URL and append the query params to it.
|
||||||
QUrl urlWithParams = networkRequest.url();
|
QUrl urlWithParams = networkRequest.url();
|
||||||
|
@ -324,6 +336,9 @@ void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) {
|
||||||
// Submit the request including the params.
|
// Submit the request including the params.
|
||||||
QNetworkReply *reply = d->networkManager->get(networkRequest);
|
QNetworkReply *reply = d->networkManager->get(networkRequest);
|
||||||
reply->ignoreSslErrors();
|
reply->ignoreSslErrors();
|
||||||
|
|
||||||
|
d->requestIds.insert(reply, id);
|
||||||
|
|
||||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||||
this, SLOT(slotError(QNetworkReply::NetworkError)));
|
this, SLOT(slotError(QNetworkReply::NetworkError)));
|
||||||
|
|
||||||
|
@ -331,6 +346,10 @@ void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) {
|
||||||
|
|
||||||
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, request->contentType());
|
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, request->contentType());
|
||||||
|
|
||||||
|
QByteArray argHeader;
|
||||||
|
argHeader.append(request->additionalParameters().value("arg"));
|
||||||
|
networkRequest.setRawHeader("Dropbox-API-Arg", argHeader);
|
||||||
|
|
||||||
qDebug() << networkRequest.rawHeaderList();
|
qDebug() << networkRequest.rawHeaderList();
|
||||||
qDebug() << networkRequest.rawHeader("Authorization");
|
qDebug() << networkRequest.rawHeader("Authorization");
|
||||||
qDebug() << networkRequest.rawHeader("Content-Type");
|
qDebug() << networkRequest.rawHeader("Content-Type");
|
||||||
|
@ -614,6 +633,7 @@ void KQOAuthManager::onAuthorizedRequestReplyReceived( QNetworkReply *reply ) {
|
||||||
Q_D(KQOAuthManager);
|
Q_D(KQOAuthManager);
|
||||||
|
|
||||||
QNetworkReply::NetworkError networkError = reply->error();
|
QNetworkReply::NetworkError networkError = reply->error();
|
||||||
|
qDebug() << networkError;
|
||||||
switch (networkError) {
|
switch (networkError) {
|
||||||
case QNetworkReply::NoError:
|
case QNetworkReply::NoError:
|
||||||
d->error = KQOAuthManager::NoError;
|
d->error = KQOAuthManager::NoError;
|
||||||
|
@ -636,6 +656,7 @@ void KQOAuthManager::onAuthorizedRequestReplyReceived( QNetworkReply *reply ) {
|
||||||
|
|
||||||
// Read the content of the reply from the network.
|
// Read the content of the reply from the network.
|
||||||
QByteArray networkReply = reply->readAll();
|
QByteArray networkReply = reply->readAll();
|
||||||
|
qDebug() << networkReply;
|
||||||
|
|
||||||
// Stop any timer we have set on the request.
|
// Stop any timer we have set on the request.
|
||||||
d->r->requestTimerStop();
|
d->r->requestTimerStop();
|
||||||
|
@ -649,6 +670,7 @@ void KQOAuthManager::onAuthorizedRequestReplyReceived( QNetworkReply *reply ) {
|
||||||
// We need to emit the signal even if we got an error.
|
// We need to emit the signal even if we got an error.
|
||||||
if (d->error != KQOAuthManager::NoError) {
|
if (d->error != KQOAuthManager::NoError) {
|
||||||
qWarning() << "Network reply error";
|
qWarning() << "Network reply error";
|
||||||
|
qDebug() << d->error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue