aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-03-23 23:03:09 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-03-25 22:35:23 +0100
commit76265ca6aa7a6c8d777aa55190d9038600ef11b1 (patch)
treebd6e9d93a8b7ad15697691dde0cccc30faa92e3b /lib
parent4c59f10262b3de2e8b808b0839d772b0d70d2057 (diff)
downloadlibquotient-76265ca6aa7a6c8d777aa55190d9038600ef11b1.tar.gz
libquotient-76265ca6aa7a6c8d777aa55190d9038600ef11b1.zip
BaseJob: Only send access token when needed
This is a basic fix for #358, without a workaround added in 5937127b (such workaround would break API compatibility).
Diffstat (limited to 'lib')
-rw-r--r--lib/jobs/basejob.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp
index a6225c67..a1f49b63 100644
--- a/lib/jobs/basejob.cpp
+++ b/lib/jobs/basejob.cpp
@@ -197,8 +197,9 @@ void BaseJob::Private::sendRequest(bool inBackground)
{ makeRequestUrl(connection->baseUrl(), apiEndpoint, requestQuery) };
if (!requestHeaders.contains("Content-Type"))
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
- req.setRawHeader("Authorization",
- QByteArray("Bearer ") + connection->accessToken());
+ if (needsToken)
+ req.setRawHeader("Authorization",
+ QByteArray("Bearer ") + connection->accessToken());
req.setAttribute(QNetworkRequest::BackgroundRequestAttribute, inBackground);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);