diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-03-23 23:03:09 +0100 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-03-25 22:35:23 +0100 |
commit | 76265ca6aa7a6c8d777aa55190d9038600ef11b1 (patch) | |
tree | bd6e9d93a8b7ad15697691dde0cccc30faa92e3b /lib/jobs | |
parent | 4c59f10262b3de2e8b808b0839d772b0d70d2057 (diff) | |
download | libquotient-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/jobs')
-rw-r--r-- | lib/jobs/basejob.cpp | 5 |
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); |