summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Larsson <karl.erik.larsson@gmail.com>2018-03-30 03:00:55 +0200
committerErik Larsson <karl.erik.larsson@gmail.com>2018-04-03 10:44:35 +0000
commita10780ceb87470f9942a8dd9d0d02374e6f97eb7 (patch)
tree85cdaf33d395605201902a35d8a7674e9ecb372e
parenta9667ae676f2633fd2d22b02d60b03ce1e025a07 (diff)
Update refresh token only if a valid one is received
When receiving a access token it is common to also receive the refresh token. But some api:s, for example Spotify[1], does not. That will result in loss of a valid refresh token. Make sure the refresh token is valid before updating it. [1] https://developer.spotify.com/web-api/authorization-guide Change-Id: If186dad353d97310d164476f89088668ffef9ca6 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
-rw-r--r--src/oauth/qoauth2authorizationcodeflow.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/oauth/qoauth2authorizationcodeflow.cpp b/src/oauth/qoauth2authorizationcodeflow.cpp
index dff04a2..03d361e 100644
--- a/src/oauth/qoauth2authorizationcodeflow.cpp
+++ b/src/oauth/qoauth2authorizationcodeflow.cpp
@@ -142,7 +142,8 @@ void QOAuth2AuthorizationCodeFlowPrivate::_q_accessTokenRequestFinished(const QV
int expiresIn = values.value(Key::expiresIn).toInt(&ok);
if (!ok)
expiresIn = -1;
- refreshToken = values.value(Key::refreshToken).toString();
+ if (values.value(Key::refreshToken).isValid())
+ refreshToken = values.value(Key::refreshToken).toString();
scope = values.value(Key::scope).toString();
if (accessToken.isEmpty()) {
qCWarning(loggingCategory, "Access token not received");