diff options
author | Jesus Fernandez <jesus.fernandez@qt.io> | 2017-05-15 16:02:28 +0200 |
---|---|---|
committer | Jesus Fernandez <Jesus.Fernandez@qt.io> | 2017-08-11 10:08:33 +0000 |
commit | 3d93f6436596e349e43c3798b675af66db71df8a (patch) | |
tree | dd1272a5238a9aac1b724c35ed93b63749a23ecd | |
parent | 61a1f8ee91a33734f12c14b25ceaff3ae05174e3 (diff) |
Allow sending custom parameters in a token refresh
Add a new Stage to pass to the parameter modification call-back so
that the client code can recognize and adapt when preparing to
refresh an access token.
[ChangeLog][QAbstractAuth] Adds a token refresh stage
allowing parameters modification.
Task-number: QTBUG-59104
Change-Id: If6cd1349df163edd27ee083e82e6f537422574ca
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r-- | src/oauth/qabstractoauth.cpp | 3 | ||||
-rw-r--r-- | src/oauth/qabstractoauth.h | 3 | ||||
-rw-r--r-- | src/oauth/qoauth2authorizationcodeflow.cpp | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/oauth/qabstractoauth.cpp b/src/oauth/qabstractoauth.cpp index 57a715d..9d88500 100644 --- a/src/oauth/qabstractoauth.cpp +++ b/src/oauth/qabstractoauth.cpp @@ -103,6 +103,9 @@ QT_BEGIN_NAMESPACE \value RequestingAccessToken Preparing the token request. + + \value RefreshingAccessToken Preparing the access + token refresh. */ /*! diff --git a/src/oauth/qabstractoauth.h b/src/oauth/qabstractoauth.h index a469e3b..c574875 100644 --- a/src/oauth/qabstractoauth.h +++ b/src/oauth/qabstractoauth.h @@ -80,7 +80,8 @@ public: enum class Stage { RequestingTemporaryCredentials, RequestingAuthorization, - RequestingAccessToken + RequestingAccessToken, + RefreshingAccessToken }; enum class Error { diff --git a/src/oauth/qoauth2authorizationcodeflow.cpp b/src/oauth/qoauth2authorizationcodeflow.cpp index f171941..86d6707 100644 --- a/src/oauth/qoauth2authorizationcodeflow.cpp +++ b/src/oauth/qoauth2authorizationcodeflow.cpp @@ -328,6 +328,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, ¶meters); query = QAbstractOAuthPrivate::createQuery(parameters); request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded")); |