From 3145b44b148e560e31e8e4a39ff3b7a2b73cf546 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 19 Dec 2024 08:37:12 +1000 Subject: [PATCH] Fix expiry message Credit to https://github.com/chenz-svsarrazin/o2/commit/62eb9d5 --- src/o2.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/o2.cpp b/src/o2.cpp index ebbb7b3..661b501 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -596,7 +596,8 @@ void O2::onRefreshFinished() { else { setToken(tokens.value(O2_OAUTH2_ACCESS_TOKEN).toString()); - setExpires(QDateTime::currentMSecsSinceEpoch() / 1000 + static_cast(tokens.value(O2_OAUTH2_EXPIRES_IN).toInt())); + const int expiresIn = tokens.value(O2_OAUTH2_EXPIRES_IN).toInt(); + setExpires(QDateTime::currentMSecsSinceEpoch() / 1000 + static_cast(expiresIn)); QString refreshToken = tokens.value(O2_OAUTH2_REFRESH_TOKEN).toString(); if(!refreshToken.isEmpty()) { setRefreshToken(refreshToken); @@ -608,7 +609,7 @@ void O2::onRefreshFinished() { setLinked(true); Q_EMIT linkingSucceeded(); Q_EMIT refreshFinished(QNetworkReply::NoError); - log( QStringLiteral(" New token expires in %1 seconds").arg( expires() ) ); + log( QStringLiteral(" New token expires in %1 seconds").arg( expiresIn ) ); } } else { log( QStringLiteral( "O2::onRefreshFinished: Error %1 %2" ).arg( (int)refreshReply->error() ).arg( refreshReply->errorString() ) );