diff options
-rw-r--r-- | src/oauth/qabstractoauth2.cpp | 28 | ||||
-rw-r--r-- | src/oauth/qabstractoauth2.h | 3 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/oauth/qabstractoauth2.cpp b/src/oauth/qabstractoauth2.cpp index d70191b..49c8f03 100644 --- a/src/oauth/qabstractoauth2.cpp +++ b/src/oauth/qabstractoauth2.cpp @@ -388,6 +388,34 @@ QDateTime QAbstractOAuth2::expirationAt() const return d->expiresAt; } +/*! + \brief Gets the current refresh token. + + Refresh tokens usually have longer lifespans than access tokens, + so it makes sense to save them for later use. + + Returns the current refresh token or an empty string, if + there is no refresh token available. +*/ +QString QAbstractOAuth2::refreshToken() const +{ + Q_D(const QAbstractOAuth2); + return d->refreshToken; +} + +/*! + \brief Sets the new refresh token \a refreshToken to be used. + + A custom refresh token can be used to refresh the access token via this method and then + the access token can be refreshed via QOAuth2AuthorizationCodeFlow::refreshAccessToken(). + +*/ +void QAbstractOAuth2::setRefreshToken(const QString &refreshToken) +{ + Q_D(QAbstractOAuth2); + d->refreshToken = refreshToken; +} + QT_END_NAMESPACE #endif // QT_NO_HTTP diff --git a/src/oauth/qabstractoauth2.h b/src/oauth/qabstractoauth2.h index c3bbd5a..0f600b2 100644 --- a/src/oauth/qabstractoauth2.h +++ b/src/oauth/qabstractoauth2.h @@ -86,6 +86,9 @@ public: QDateTime expirationAt() const; + QString refreshToken() const; + void setRefreshToken(const QString &refreshToken); + Q_SIGNALS: void scopeChanged(const QString &scope); void userAgentChanged(const QString &userAgent); |