diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 1100371ac9..b24f720edf 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -25,6 +25,8 @@ const bool VERBOSE_HTTP_REQUEST_DEBUGGING = false; +const QByteArray ACCESS_TOKEN_AUTHORIZATION_HEADER = "Authorization"; + AccountManager& AccountManager::getInstance() { static AccountManager sharedInstance; return sharedInstance; @@ -188,7 +190,8 @@ void AccountManager::invokedRequest(const QString& path, if (requiresAuthentication) { if (hasValidAccessToken()) { - requestURL.setQuery("access_token=" + _accountInfo.getAccessToken().token); + networkRequest.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER, + _accountInfo.getAccessToken().authorizationHeaderValue()); } else { qDebug() << "No valid access token present. Bailing on authenticated invoked request."; return; @@ -405,9 +408,11 @@ void AccountManager::requestProfile() { QUrl profileURL = _authURL; profileURL.setPath("/api/v1/users/profile"); - profileURL.setQuery("access_token=" + _accountInfo.getAccessToken().token); + + QNetworkRequest profileRequest(profileURL); + profileRequest.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER, _accountInfo.getAccessToken().authorizationHeaderValue()); - QNetworkReply* profileReply = networkAccessManager.get(QNetworkRequest(profileURL)); + QNetworkReply* profileReply = networkAccessManager.get(profileRequest); connect(profileReply, &QNetworkReply::finished, this, &AccountManager::requestProfileFinished); connect(profileReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestProfileError(QNetworkReply::NetworkError))); } diff --git a/libraries/networking/src/OAuthAccessToken.h b/libraries/networking/src/OAuthAccessToken.h index 36859b79f8..167bb824da 100644 --- a/libraries/networking/src/OAuthAccessToken.h +++ b/libraries/networking/src/OAuthAccessToken.h @@ -23,6 +23,8 @@ public: OAuthAccessToken(const QJsonObject& jsonObject); OAuthAccessToken(const OAuthAccessToken& otherToken); OAuthAccessToken& operator=(const OAuthAccessToken& otherToken); + + QByteArray authorizationHeaderValue() const { return QString("Bearer %1").arg(token).toUtf8(); } bool isExpired() const { return expiryTimestamp <= QDateTime::currentMSecsSinceEpoch(); }