summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Larsson <karl.erik.larsson@gmail.com>2018-03-30 11:44:13 +0200
committerErik Larsson <karl.erik.larsson@gmail.com>2018-04-04 10:48:32 +0000
commit6b8ac5e36f5f0eaabb2fdc6720394a77b6264954 (patch)
treea5fad9a146558a620091dd4c9c80bf762d2b8380
parenta10780ceb87470f9942a8dd9d0d02374e6f97eb7 (diff)
Add property for refreshToken
Add a property to the already available C++ API for refreshToken. Change-Id: I34be1dd2a7b234cd7a24d8e56f959b8624269216 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
-rw-r--r--src/oauth/qabstractoauth2.cpp5
-rw-r--r--src/oauth/qabstractoauth2.h5
-rw-r--r--src/oauth/qoauth2authorizationcodeflow.cpp2
3 files changed, 10 insertions, 2 deletions
diff --git a/src/oauth/qabstractoauth2.cpp b/src/oauth/qabstractoauth2.cpp
index 63f8ade..1f7f6ee 100644
--- a/src/oauth/qabstractoauth2.cpp
+++ b/src/oauth/qabstractoauth2.cpp
@@ -436,7 +436,10 @@ QString QAbstractOAuth2::refreshToken() const
void QAbstractOAuth2::setRefreshToken(const QString &refreshToken)
{
Q_D(QAbstractOAuth2);
- d->refreshToken = refreshToken;
+ if (d->refreshToken != refreshToken) {
+ d->refreshToken = refreshToken;
+ Q_EMIT refreshTokenChanged(refreshToken);
+ }
}
QT_END_NAMESPACE
diff --git a/src/oauth/qabstractoauth2.h b/src/oauth/qabstractoauth2.h
index 9262170..a5bdd02 100644
--- a/src/oauth/qabstractoauth2.h
+++ b/src/oauth/qabstractoauth2.h
@@ -52,6 +52,10 @@ class Q_OAUTH_EXPORT QAbstractOAuth2 : public QAbstractOAuth
NOTIFY clientIdentifierSharedKeyChanged)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(QDateTime expiration READ expirationAt NOTIFY expirationAtChanged)
+ Q_PROPERTY(QString refreshToken
+ READ refreshToken
+ WRITE setRefreshToken
+ NOTIFY refreshTokenChanged)
public:
explicit QAbstractOAuth2(QObject *parent = nullptr);
@@ -101,6 +105,7 @@ Q_SIGNALS:
void clientIdentifierSharedKeyChanged(const QString &clientIdentifierSharedKey);
void stateChanged(const QString &state);
void expirationAtChanged(const QDateTime &expiration);
+ void refreshTokenChanged(const QString &refreshToken);
void error(const QString &error, const QString &errorDescription, const QUrl &uri);
void authorizationCallbackReceived(const QVariantMap &data);
diff --git a/src/oauth/qoauth2authorizationcodeflow.cpp b/src/oauth/qoauth2authorizationcodeflow.cpp
index 03d361e..3bc94e6 100644
--- a/src/oauth/qoauth2authorizationcodeflow.cpp
+++ b/src/oauth/qoauth2authorizationcodeflow.cpp
@@ -143,7 +143,7 @@ void QOAuth2AuthorizationCodeFlowPrivate::_q_accessTokenRequestFinished(const QV
if (!ok)
expiresIn = -1;
if (values.value(Key::refreshToken).isValid())
- refreshToken = values.value(Key::refreshToken).toString();
+ q->setRefreshToken(values.value(Key::refreshToken).toString());
scope = values.value(Key::scope).toString();
if (accessToken.isEmpty()) {
qCWarning(loggingCategory, "Access token not received");