aboutsummaryrefslogtreecommitdiff
path: root/libraries/katabasis/src/OAuth2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/katabasis/src/OAuth2.cpp')
-rw-r--r--libraries/katabasis/src/OAuth2.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/libraries/katabasis/src/OAuth2.cpp b/libraries/katabasis/src/OAuth2.cpp
index 6cc03a0d..9756d377 100644
--- a/libraries/katabasis/src/OAuth2.cpp
+++ b/libraries/katabasis/src/OAuth2.cpp
@@ -472,16 +472,8 @@ void OAuth2::setExpires(QDateTime v) {
token_.notAfter = v;
}
-void OAuth2::startPollServer(const QVariantMap &params)
+void OAuth2::startPollServer(const QVariantMap &params, int expiresIn)
{
- bool ok = false;
- int expiresIn = params[OAUTH2_EXPIRES_IN].toInt(&ok);
- if (!ok) {
- qWarning() << "OAuth2::startPollServer: No expired_in parameter";
- emit linkingFailed();
- return;
- }
-
qDebug() << "OAuth2::startPollServer: device_ and user_code expires in" << expiresIn << "seconds";
QUrl url(options_.accessTokenUrl);
@@ -502,6 +494,7 @@ void OAuth2::startPollServer(const QVariantMap &params)
PollServer * pollServer = new PollServer(manager_, authRequest, payload, expiresIn, this);
if (params.contains(OAUTH2_INTERVAL)) {
+ bool ok = false;
int interval = params[OAUTH2_INTERVAL].toInt(&ok);
if (ok)
pollServer->setInterval(interval);
@@ -516,7 +509,9 @@ QString OAuth2::refreshToken() {
return token_.refresh_token;
}
void OAuth2::setRefreshToken(const QString &v) {
+#ifndef NDEBUG
qDebug() << "OAuth2::setRefreshToken" << v << "...";
+#endif
token_.refresh_token = v;
}
@@ -573,7 +568,7 @@ void OAuth2::onRefreshFinished() {
setLinked(true);
emit linkingSucceeded();
emit refreshFinished(QNetworkReply::NoError);
- qDebug() << " New token expires in" << expires() << "seconds";
+ qDebug() << "New token expires in" << expires() << "seconds";
} else {
qDebug() << "OAuth2::onRefreshFinished: Error" << (int)refreshReply->error() << refreshReply->errorString();
}
@@ -627,9 +622,17 @@ void OAuth2::onDeviceAuthReplyFinished()
if (params.contains(OAUTH2_VERIFICATION_URI_COMPLETE))
emit openBrowser(params.take(OAUTH2_VERIFICATION_URI_COMPLETE).toUrl());
- emit showVerificationUriAndCode(uri, userCode);
+ bool ok = false;
+ int expiresIn = params[OAUTH2_EXPIRES_IN].toInt(&ok);
+ if (!ok) {
+ qWarning() << "OAuth2::startPollServer: No expired_in parameter";
+ emit linkingFailed();
+ return;
+ }
+
+ emit showVerificationUriAndCode(uri, userCode, expiresIn);
- startPollServer(params);
+ startPollServer(params, expiresIn);
} else {
qWarning() << "OAuth2::onDeviceAuthReplyFinished: Mandatory parameters missing from response";
emit linkingFailed();