[SCM] ktp-auth-handler packaging branch, master, updated. debian/15.12.1-2-282-g080758e
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 23:58:35 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-auth-handler.git;a=commitdiff;h=98e7a30
The following commit has been merged in the master branch:
commit 98e7a30d2174e638361e38ff4091dc6e7de13a3a
Author: Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
Date: Mon Dec 26 01:13:25 2011 +0100
Fix X-MESSENGER-OAUTH2 authentication with QtWebkit >= 2.2
---
x-messenger-oauth2-prompt.cpp | 47 +++++++++++++++++++++++++++++++------------
x-messenger-oauth2-prompt.h | 2 ++
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/x-messenger-oauth2-prompt.cpp b/x-messenger-oauth2-prompt.cpp
index a931040..6f8ea91 100644
--- a/x-messenger-oauth2-prompt.cpp
+++ b/x-messenger-oauth2-prompt.cpp
@@ -34,6 +34,8 @@
const QLatin1String msnClientID("000000004C070A47");
const QLatin1String redirectUri("https://oauth.live.com/desktop");
+const QLatin1String request("https://oauth.live.com/authorize?response_type=token&redirect_uri=%1&client_id=%2&scope=wl.messenger");
+const QLatin1String tokenParameter("access_token=");
XMessengerOAuth2Prompt::XMessengerOAuth2Prompt(QWidget* parent) :
KDialog(parent),
@@ -94,7 +96,7 @@ XMessengerOAuth2Prompt::XMessengerOAuth2Prompt(QWidget* parent) :
SLOT(onUnsupportedContent(QNetworkReply*)));
// start loading the login URL
- KUrl url(QString(QLatin1String("https://oauth.live.com/authorize?response_type=token&redirect_uri=%1&client_id=%2&scope=wl.messenger")).arg(redirectUri).arg(msnClientID));
+ KUrl url(QString(request).arg(redirectUri).arg(msnClientID));
m_webView->load(url.url());
}
@@ -114,9 +116,12 @@ QSize XMessengerOAuth2Prompt::sizeHint() const
void XMessengerOAuth2Prompt::onUrlChanged(const QUrl &url)
{
- // FIXME: This method is left for debugging purpose
kDebug() << url;
- kDebug() << m_webView->url();
+ if (url.toString().indexOf(redirectUri) != 0) {
+ // This is not the url containing the token
+ return;
+ }
+ extractToken(url);
}
void XMessengerOAuth2Prompt::onLinkClicked(const QUrl& url)
@@ -135,26 +140,42 @@ void XMessengerOAuth2Prompt::onLoadFinished(bool ok)
void XMessengerOAuth2Prompt::onUnsupportedContent(QNetworkReply* reply)
{
- // For some reason the request for the token is unsupported, but we
- // Can extract the token from the url of the failing request
- // FIXME: In the future this might need to be fixed
+ // With QtWebkit < 2.2, for some reason the request for the token is
+ // unsupported, but we can extract the token from the url of the failing
+ // request
+ // FIXME: In the future this might want to remove this
QUrl url = reply->url();
if (url.toString().indexOf(redirectUri) != 0) {
// This is not the url containing the token
return;
}
- QString accessToken = url.encodedFragment(); // Get the URL fragment part
- accessToken = accessToken.split("&").first(); // Remove the "expires_in" part.
+ extractToken(url);
+}
+
+void XMessengerOAuth2Prompt::extractToken(const QUrl &url)
+{
+ QString accessToken;
+ Q_FOREACH(QString token, QString(url.encodedFragment()).split("&")) {
+ // Get the URL fragment part and iterate over the parameters of the request
+ if (token.indexOf(tokenParameter == 0)) {
+ // This is the token that we are looking for (we are not interested
+ // in the "expires_in" part, etc.)
+ accessToken = token;
+ break;
+ }
+ }
+ if (accessToken.isEmpty()) {
+ // Could not find the token
+ kWarning() << "Token not found";
+ return;
+ }
+
+ accessToken = accessToken.split("&").first(); //
accessToken = accessToken.split("=").at(1); // Split by "access_token=..." and take latter part
// Wocky will base64 encode, but token actually already is base64, so we
// decode now and it will be re-encoded.
m_accessToken = QByteArray::fromBase64(QByteArray::fromPercentEncoding(accessToken.toUtf8()));
- kDebug() << "size = " << m_accessToken.size();
- char* data = QByteArray::fromBase64(QByteArray::fromPercentEncoding(accessToken.toUtf8())).data();
- for (int i = 0; i < m_accessToken.size(); i++, data++) {
- kDebug() << i << "[" << *data << "]" << endl;
- }
Q_EMIT accessTokenTaken(m_accessToken);
accept();
}
diff --git a/x-messenger-oauth2-prompt.h b/x-messenger-oauth2-prompt.h
index d08d291..c87d6e7 100644
--- a/x-messenger-oauth2-prompt.h
+++ b/x-messenger-oauth2-prompt.h
@@ -49,6 +49,8 @@ private Q_SLOTS:
void onUnsupportedContent(QNetworkReply* reply);
private:
+ void extractToken(const QUrl &url);
+
KWebView *m_webView;
QProgressBar *m_ProgressBar;
bool m_loginPageLoaded;
--
ktp-auth-handler packaging
More information about the pkg-kde-commits
mailing list