From 17ed2aa04aa42b21a0fd0fa16b6a5fbe7b0e041d Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sat, 6 Mar 2021 20:29:13 +0100 Subject: [PATCH] include encrypted feedly tokenss --- .github/workflows/rssguard.yml | 2 ++ .../services/feedly/feedlynetwork.cpp | 6 ++--- .../services/feedly/feedlyserviceroot.cpp | 12 ++++++++-- .../feedly/gui/feedlyaccountdetails.cpp | 8 +------ .../feedly/gui/formeditfeedlyaccount.cpp | 23 ++----------------- 5 files changed, 18 insertions(+), 33 deletions(-) diff --git a/.github/workflows/rssguard.yml b/.github/workflows/rssguard.yml index 08cbc939c..db5e718bf 100755 --- a/.github/workflows/rssguard.yml +++ b/.github/workflows/rssguard.yml @@ -48,6 +48,8 @@ jobs: GMAIL_CLIENT_SECRET: ${{ secrets.GMAIL_CLIENT_SECRET }} INOREADER_CLIENT_ID: ${{ secrets.INOREADER_CLIENT_ID }} INOREADER_CLIENT_SECRET: ${{ secrets.INOREADER_CLIENT_SECRET }} + FEEDLY_CLIENT_ID: ${{ secrets.FEEDLY_CLIENT_ID }} + FEEDLY_CLIENT_SECRET: ${{ secrets.FEEDLY_CLIENT_SECRET }} - name: Release development binaries uses: softprops/action-gh-release@v1 diff --git a/src/librssguard/services/feedly/feedlynetwork.cpp b/src/librssguard/services/feedly/feedlynetwork.cpp index 35cedcde0..c619068aa 100755 --- a/src/librssguard/services/feedly/feedlynetwork.cpp +++ b/src/librssguard/services/feedly/feedlynetwork.cpp @@ -4,9 +4,9 @@ #include "3rd-party/boolinq/boolinq.h" #include "3rd-party/boolinq/boolinq.h" +#include "database/databasequeries.h" #include "exceptions/networkexception.h" #include "miscellaneous/application.h" -#include "database/databasequeries.h" #include "network-web/networkfactory.h" #include "network-web/webfactory.h" #include "services/abstract/category.h" @@ -28,8 +28,8 @@ FeedlyNetwork::FeedlyNetwork(QObject* parent) #if defined(FEEDLY_OFFICIAL_SUPPORT) m_oauth(new OAuth2Service(QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_AUTH, QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_TOKEN, - FEEDLY_CLIENT_ID, - FEEDLY_CLIENT_ID, + TextFactory::decrypt(FEEDLY_CLIENT_ID, OAUTH_DECRYPTION_KEY), + TextFactory::decrypt(FEEDLY_CLIENT_SECRET, OAUTH_DECRYPTION_KEY), FEEDLY_API_SCOPE, this)), #endif m_username(QString()), diff --git a/src/librssguard/services/feedly/feedlyserviceroot.cpp b/src/librssguard/services/feedly/feedlyserviceroot.cpp index 2971cdefb..191c2ac69 100755 --- a/src/librssguard/services/feedly/feedlyserviceroot.cpp +++ b/src/librssguard/services/feedly/feedlyserviceroot.cpp @@ -2,11 +2,11 @@ #include "services/feedly/feedlyserviceroot.h" +#include "database/databasequeries.h" #include "definitions/definitions.h" #include "exceptions/applicationexception.h" #include "exceptions/networkexception.h" #include "miscellaneous/application.h" -#include "database/databasequeries.h" #include "miscellaneous/iconfactory.h" #include "miscellaneous/mutex.h" #include "miscellaneous/textfactory.h" @@ -105,8 +105,16 @@ void FeedlyServiceRoot::start(bool freshly_activated) { updateTitle(); if (getSubTreeFeeds().isEmpty()) { - syncIn(); + m_network->oauth()->login([this]() { + syncIn(); + }); } + +#if defined(FEEDLY_OFFICIAL_SUPPORT) + else { + m_network->oauth()->login(); + } +#endif } QString FeedlyServiceRoot::code() const { diff --git a/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp b/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp index b514d2852..ddd807ba8 100755 --- a/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp +++ b/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp @@ -19,13 +19,7 @@ FeedlyAccountDetails::FeedlyAccountDetails(QWidget* parent) : QWidget(parent) { #if defined(FEEDLY_OFFICIAL_SUPPORT) - m_oauth = new OAuth2Service(QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_AUTH, - QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_TOKEN, - FEEDLY_CLIENT_ID, - FEEDLY_CLIENT_SECRET, - FEEDLY_API_SCOPE, this); - - m_oauth->setRedirectUrl(QString(OAUTH_REDIRECT_URI) + QL1C(':') + QString::number(FEEDLY_API_REDIRECT_URI_PORT)); + m_oauth = nullptr; #endif m_ui.setupUi(this); diff --git a/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp b/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp index a58ef16ee..4f85d6648 100755 --- a/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp +++ b/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp @@ -27,20 +27,7 @@ void FormEditFeedlyAccount::apply() { FormAccountDetails::apply(); #if defined(FEEDLY_OFFICIAL_SUPPORT) - if (!m_creatingNew) { - // We transfer refresh token to avoid the need to login once more, - // then we delete testing OAuth service. - account()->network()->oauth()->setAccessToken(m_details->m_oauth->accessToken()); - account()->network()->oauth()->setRefreshToken(m_details->m_oauth->refreshToken()); - account()->network()->oauth()->setTokensExpireIn(m_details->m_oauth->tokensExpireIn()); - m_details->m_oauth->logout(true); - m_details->m_oauth->deleteLater(); - - // Force live OAuth object to re-start it's redirection handler. - account()->network()->oauth()->setRedirectUrl(QString(OAUTH_REDIRECT_URI) + - QL1C(':') + - QString::number(FEEDLY_API_REDIRECT_URI_PORT)); - } + account()->network()->oauth()->logout(false); #endif account()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text()); @@ -53,7 +40,7 @@ void FormEditFeedlyAccount::apply() { if (!m_creatingNew) { account()->completelyRemoveAllData(); - account()->syncIn(); + account()->start(true); } } @@ -61,12 +48,6 @@ void FormEditFeedlyAccount::loadAccountData() { FormAccountDetails::loadAccountData(); #if defined(FEEDLY_OFFICIAL_SUPPORT) - if (m_details->m_oauth != nullptr) { - // We will use live OAuth service for testing. - m_details->m_oauth->logout(true); - m_details->m_oauth->deleteLater(); - } - m_details->m_oauth = account()->network()->oauth(); m_details->hookNetwork(); #endif