diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2019-11-18 15:26:05 +0300 |
---|---|---|
committer | Markus Goetz <markus@woboq.com> | 2019-11-20 16:32:57 +0300 |
commit | d3e02b9bbba279f05ea2d611925e20792fd16709 (patch) | |
tree | d1db63827d1fb03b6e5f7f58f9af7b6fdb31d2f6 /src/gui/creds | |
parent | 112e78ba944148b73ef96d5d61e6838457df56a8 (diff) |
OAuth: fix review comment from #7509
Diffstat (limited to 'src/gui/creds')
-rw-r--r-- | src/gui/creds/oauth.cpp | 12 | ||||
-rw-r--r-- | src/gui/creds/oauth.h | 3 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/gui/creds/oauth.cpp b/src/gui/creds/oauth.cpp index 63f0b5323..44cd3bb1e 100644 --- a/src/gui/creds/oauth.cpp +++ b/src/gui/creds/oauth.cpp @@ -100,9 +100,12 @@ void OAuth::start() req.setAttribute(HttpCredentials::DontAddCredentialsAttribute, true); auto requestBody = new QBuffer; - QUrlQuery arguments(QString( - "grant_type=authorization_code&code=%1&redirect_uri=http://localhost:%2&code_verifier=%3&scope=openid offline_access") - .arg(code, QString::number(_server.serverPort()), _pkceCodeVerifier)); + QUrlQuery arguments { + { "grant_type", "authorization_code" }, + { "code" , code }, + { "redirect_uri", QString("http://localhost:%1").arg(_server.serverPort()) }, + { "code_verifier", _pkceCodeVerifier }, + { "scope", "openid offline_access" }}; requestBody->setData(arguments.query(QUrl::FullyEncoded).toLatin1()); auto job = _account->sendRequest("POST", requestToken, req, requestBody); job->setTimeout(qMin(30 * 1000ll, job->timeoutMsec())); @@ -121,7 +124,7 @@ void OAuth::start() QString errorReason; QString errorFromJson = json["error_description"].toString(); if (errorFromJson.isEmpty()) - QString errorFromJson = json["error"].toString(); + errorFromJson = json["error"].toString(); if (!errorFromJson.isEmpty()) { errorReason = tr("Error returned from the server: <em>%1</em>") .arg(errorFromJson.toHtmlEscaped()); @@ -260,6 +263,7 @@ void OAuth::openBrowser() { authorisationLinkAsync([this](const QUrl &link) { if (!QDesktopServices::openUrl(link)) { + qCWarning(lcOauth) << "QDesktopServices::openUrl Failed"; // We cannot open the browser, then we claim we don't support OAuth. emit result(NotSupported, QString()); } diff --git a/src/gui/creds/oauth.h b/src/gui/creds/oauth.h index e4bf09134..a947d4671 100644 --- a/src/gui/creds/oauth.h +++ b/src/gui/creds/oauth.h @@ -29,7 +29,8 @@ namespace OCC { * | * +----> fetchWellKnown() query the ".well-known/openid-configuration" endpoint * | - * +----> openBrowser() open the browser to the login page after fetchWellKnown finished. + * +----> openBrowser() open the browser after fetchWellKnown finished to the specified page + * | (or the default 'oauth2/authorize' if fetchWellKnown does not exist) * | Then the browser will redirect to http://localhost:xxx * | * +----> _server starts listening on a TCP port waiting for an HTTP request with a 'code' |