summaryrefslogtreecommitdiffstats
path: root/src/oauth/qoauth2authorizationcodeflow.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-08-22 08:41:53 +0200
committerLiang Qi <liang.qi@qt.io>2017-08-22 08:44:53 +0200
commit461a29be564271ef3a6ca1728f5e48ec2d25c08d (patch)
tree27e9b0f90bc09e59fd31b2a5052e0c6f7327c467 /src/oauth/qoauth2authorizationcodeflow.cpp
parent095d29d1afe10569ea3c2b4d834bc832b3ebaf9a (diff)
parent3d93f6436596e349e43c3798b675af66db71df8a (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: .qmake.conf src/oauth/qabstractoauth.cpp tests/auto/oauth1/tst_oauth1.cpp Done-with: Jesus Fernandez<jesus.fernandez@qt.io> Change-Id: I5be2c6ad2cd00943ee3acafe5b5c693fc4ada03c
Diffstat (limited to 'src/oauth/qoauth2authorizationcodeflow.cpp')
-rw-r--r--src/oauth/qoauth2authorizationcodeflow.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/oauth/qoauth2authorizationcodeflow.cpp b/src/oauth/qoauth2authorizationcodeflow.cpp
index b5634d6..dff04a2 100644
--- a/src/oauth/qoauth2authorizationcodeflow.cpp
+++ b/src/oauth/qoauth2authorizationcodeflow.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Network Auth module of the Qt Toolkit.
@@ -316,6 +316,8 @@ void QOAuth2AuthorizationCodeFlow::refreshAccessToken()
parameters.insert(Key::grantType, QStringLiteral("refresh_token"));
parameters.insert(Key::refreshToken, d->refreshToken);
parameters.insert(Key::redirectUri, QUrl::toPercentEncoding(callback()));
+ if (d->modifyParametersFunction)
+ d->modifyParametersFunction(Stage::RefreshingAccessToken, &parameters);
query = QAbstractOAuthPrivate::createQuery(parameters);
request.setHeader(QNetworkRequest::ContentTypeHeader,
QStringLiteral("application/x-www-form-urlencoded"));
@@ -324,11 +326,11 @@ void QOAuth2AuthorizationCodeFlow::refreshAccessToken()
d->currentReply = d->networkAccessManager()->post(request, data.toUtf8());
d->status = Status::RefreshingToken;
- connect(d->currentReply.data(), &QNetworkReply::finished,
- std::bind(&QAbstractOAuthReplyHandler::networkReplyFinished, replyHandler(),
- d->currentReply.data()));
- connect(d->currentReply.data(), &QNetworkReply::finished, d->currentReply.data(),
- &QNetworkReply::deleteLater);
+ QNetworkReply *reply = d->currentReply.data();
+ QAbstractOAuthReplyHandler *handler = replyHandler();
+ connect(reply, &QNetworkReply::finished,
+ [handler, reply]() { handler->networkReplyFinished(reply); });
+ connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
QObjectPrivate::connect(d->networkAccessManager(),
&QNetworkAccessManager::authenticationRequired,
d, &QOAuth2AuthorizationCodeFlowPrivate::_q_authenticate,
@@ -393,10 +395,11 @@ void QOAuth2AuthorizationCodeFlow::requestAccessToken(const QString &code)
QStringLiteral("application/x-www-form-urlencoded"));
const QString data = query.toString(QUrl::FullyEncoded);
- d->currentReply = d->networkAccessManager()->post(request, data.toUtf8());
- QObject::connect(d->currentReply.data(), &QNetworkReply::finished,
- std::bind(&QAbstractOAuthReplyHandler::networkReplyFinished, replyHandler(),
- d->currentReply.data()));
+ QNetworkReply *reply = d->networkAccessManager()->post(request, data.toUtf8());
+ d->currentReply = reply;
+ QAbstractOAuthReplyHandler *handler = replyHandler();
+ QObject::connect(reply, &QNetworkReply::finished,
+ [handler, reply] { handler->networkReplyFinished(reply); });
QObjectPrivate::connect(d->replyHandler.data(), &QAbstractOAuthReplyHandler::tokensReceived, d,
&QOAuth2AuthorizationCodeFlowPrivate::_q_accessTokenRequestFinished,
Qt::UniqueConnection);