OAuth: cleanup debug messages
authorOlivier Goffart <ogoffart@woboq.com>
Tue, 13 Jun 2017 08:24:26 +0000 (10:24 +0200)
committerOlivier Goffart <olivier@woboq.com>
Tue, 13 Jun 2017 10:08:24 +0000 (12:08 +0200)
- 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)

src/gui/creds/oauth.cpp
src/libsync/abstractnetworkjob.cpp
src/libsync/creds/httpcredentials.cpp

index 2022995c28d2b0930d91573c18727a2e758f87d7..38e279d29374fcc03d67f1f89452e501b6f96829 100644 (file)
 #include <QJsonDocument>
 #include "theme.h"
 
-
 namespace OCC {
 
+Q_LOGGING_CATEGORY(lcOauth, "sync.credentials.oauth", QtInfoMsg)
+
 OAuth::~OAuth()
 {
 }
@@ -89,7 +90,7 @@ void OAuth::start()
                     if (reply->error() != QNetworkReply::NoError || jsonParseError.error != QJsonParseError::NoError
                         || json.isEmpty() || refreshToken.isEmpty() || accessToken.isEmpty()
                         || 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);
                         return;
                     }
index 25fe28ce38a13ac853b0dd902d595303907f789a..71984a66abb1a9b015da9ad9f6fd0a5d62a2d38d 100644 (file)
@@ -152,10 +152,12 @@ void AbstractNetworkJob::slotFinished()
     }
 
     if (_reply->error() != QNetworkReply::NoError) {
-        qCWarning(lcNetworkJob) << _reply->error() << errorString()
-                                << _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
-        if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) {
-            qCWarning(lcNetworkJob) << _reply->rawHeader("Proxy-Authenticate");
+        if (!_ignoreCredentialFailure || _reply->error() != QNetworkReply::AuthenticationRequiredError) {
+            qCWarning(lcNetworkJob) << _reply->error() << errorString()
+                                    << _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
+            if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) {
+                qCWarning(lcNetworkJob) << _reply->rawHeader("Proxy-Authenticate");
+            }
         }
         emit networkError(_reply);
     }
index 5601d9ae8397706a11e550fe7d566ae10b41818d..ce37ce93ee4677073c920fbbda830300fe44071a 100644 (file)
@@ -181,7 +181,6 @@ void HttpCredentials::fetchFromKeychain()
         addSettingsToJob(_account, job);
         job->setInsecureFallback(false);
         job->setKey(kck);
-        qCDebug(lcHttpCredentials) << "-------- ----->" << _clientSslCertificate << _clientSslKey;
 
         connect(job, SIGNAL(finished(QKeychain::Job *)), SLOT(slotReadClientCertPEMJobDone(QKeychain::Job *)));
         job->start();
@@ -310,10 +309,10 @@ void HttpCredentials::refreshAccessToken()
         QString accessToken = json["access_token"].toString();
         if (reply->error() != QNetworkReply::NoError || jsonParseError.error != QJsonParseError::NoError || json.isEmpty()) {
             // 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()) {
             // The token is no longer valid.
-            qDebug() << "Expired refresh token. Logging out";
+            qCDebug(lcHttpCredentials) << "Expired refresh token. Logging out";
             _refreshToken.clear();
         } else {
             _ready = true;