aboutsummaryrefslogtreecommitdiff
path: root/jobs
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-10-27 21:22:04 +0300
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-10-27 21:22:04 +0300
commita7f158d1cfdc5c572a62af5a6945e4a6b88e8253 (patch)
tree8d62fdd9f2fb77d73e9fb70703078b433be28079 /jobs
parent8214e671ec0e0df90f0b7cfa0304f0b6ac99d189 (diff)
downloadlibquotient-a7f158d1cfdc5c572a62af5a6945e4a6b88e8253.tar.gz
libquotient-a7f158d1cfdc5c572a62af5a6945e4a6b88e8253.zip
Put access token to headers instead of query
Diffstat (limited to 'jobs')
-rw-r--r--jobs/basejob.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp
index aa47f63c..20fb68f6 100644
--- a/jobs/basejob.cpp
+++ b/jobs/basejob.cpp
@@ -82,9 +82,9 @@ inline QDebug operator<<(QDebug dbg, const BaseJob* j)
QDebug QMatrixClient::operator<<(QDebug dbg, const BaseJob::Status& s)
{
- QRegularExpression filter { "(access_token)=[-_A-Za-z0-9]+" };
+ QRegularExpression filter { "(access_token)(=|: )[-_A-Za-z0-9]+" };
return dbg << s.code << ':'
- << QString(s.message).replace(filter, "\\1=HIDDEN");
+ << QString(s.message).replace(filter, "\\1 HIDDEN");
}
BaseJob::BaseJob(HttpVerb verb, const QString& name, const QString& endpoint,
@@ -138,13 +138,12 @@ void BaseJob::Private::sendRequest()
{
QUrl url = connection->baseUrl();
url.setPath( url.path() + "/" + apiEndpoint );
- QUrlQuery q = requestQuery;
- if (needsToken)
- q.addQueryItem("access_token", connection->accessToken());
- url.setQuery(q);
+ url.setQuery(requestQuery);
QNetworkRequest req {url};
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
+ req.setRawHeader(QByteArray("Authorization"),
+ QByteArray("Bearer ") + connection->accessToken());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
req.setMaximumRedirectsAllowed(10);