OAuth: cleanup debug messages

- Add category to the all messages (they did not have it was merged right after
the patch to add category everywhere, but this code did not have it.)

- Make sure there is no warnings in the normal flow. (The wizard does a request
without authentication to determine the auth type)
This commit is contained in:
Olivier Goffart 2017-06-13 10:24:26 +02:00 committed by Olivier Goffart
parent 6e57b0219e
commit 5100a2daf1
3 changed files with 11 additions and 9 deletions

View file

@ -21,9 +21,10 @@
#include <QJsonDocument> #include <QJsonDocument>
#include "theme.h" #include "theme.h"
namespace OCC { namespace OCC {
Q_LOGGING_CATEGORY(lcOauth, "sync.credentials.oauth", QtInfoMsg)
OAuth::~OAuth() OAuth::~OAuth()
{ {
} }
@ -89,7 +90,7 @@ void OAuth::start()
if (reply->error() != QNetworkReply::NoError || jsonParseError.error != QJsonParseError::NoError if (reply->error() != QNetworkReply::NoError || jsonParseError.error != QJsonParseError::NoError
|| json.isEmpty() || refreshToken.isEmpty() || accessToken.isEmpty() || json.isEmpty() || refreshToken.isEmpty() || accessToken.isEmpty()
|| json["token_type"].toString() != QLatin1String("Bearer")) { || json["token_type"].toString() != QLatin1String("Bearer")) {
qDebug() << "Error when getting the accessToken" << reply->error() << json << jsonParseError.errorString(); qCWarning(lcOauth) << "Error when getting the accessToken" << reply->error() << json << jsonParseError.errorString();
emit result(Error); emit result(Error);
return; return;
} }

View file

@ -152,11 +152,13 @@ void AbstractNetworkJob::slotFinished()
} }
if (_reply->error() != QNetworkReply::NoError) { if (_reply->error() != QNetworkReply::NoError) {
if (!_ignoreCredentialFailure || _reply->error() != QNetworkReply::AuthenticationRequiredError) {
qCWarning(lcNetworkJob) << _reply->error() << errorString() qCWarning(lcNetworkJob) << _reply->error() << errorString()
<< _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); << _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) { if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) {
qCWarning(lcNetworkJob) << _reply->rawHeader("Proxy-Authenticate"); qCWarning(lcNetworkJob) << _reply->rawHeader("Proxy-Authenticate");
} }
}
emit networkError(_reply); emit networkError(_reply);
} }

View file

@ -181,7 +181,6 @@ void HttpCredentials::fetchFromKeychain()
addSettingsToJob(_account, job); addSettingsToJob(_account, job);
job->setInsecureFallback(false); job->setInsecureFallback(false);
job->setKey(kck); job->setKey(kck);
qCDebug(lcHttpCredentials) << "-------- ----->" << _clientSslCertificate << _clientSslKey;
connect(job, SIGNAL(finished(QKeychain::Job *)), SLOT(slotReadClientCertPEMJobDone(QKeychain::Job *))); connect(job, SIGNAL(finished(QKeychain::Job *)), SLOT(slotReadClientCertPEMJobDone(QKeychain::Job *)));
job->start(); job->start();
@ -310,10 +309,10 @@ void HttpCredentials::refreshAccessToken()
QString accessToken = json["access_token"].toString(); QString accessToken = json["access_token"].toString();
if (reply->error() != QNetworkReply::NoError || jsonParseError.error != QJsonParseError::NoError || json.isEmpty()) { if (reply->error() != QNetworkReply::NoError || jsonParseError.error != QJsonParseError::NoError || json.isEmpty()) {
// Network error maybe? // Network error maybe?
qDebug() << "Error while refreshing the token" << reply->errorString() << jsonData << jsonParseError.errorString(); qCWarning(lcHttpCredentials) << "Error while refreshing the token" << reply->errorString() << jsonData << jsonParseError.errorString();
} else if (accessToken.isEmpty()) { } else if (accessToken.isEmpty()) {
// The token is no longer valid. // The token is no longer valid.
qDebug() << "Expired refresh token. Logging out"; qCDebug(lcHttpCredentials) << "Expired refresh token. Logging out";
_refreshToken.clear(); _refreshToken.clear();
} else { } else {
_ready = true; _ready = true;