More fixes for OAuth.

This commit is contained in:
Martin Rotter 2020-07-24 09:09:07 +02:00
parent 9d6b40e476
commit e1a73c9257
6 changed files with 69 additions and 0 deletions

View File

@ -15,6 +15,10 @@ FormEditGmailAccount::FormEditGmailAccount(QWidget* parent)
GuiUtilities::applyDialogProperties(*this, qApp->icons()->miscIcon(QSL("gmail")));
GuiUtilities::setLabelAsNotice(*m_ui.m_lblInfo, true);
m_ui.m_lblInfo->setText(tr("Specified redirect URL must start with \"http://localhost\" and "
"must be configured in your OAuth \"application\"."));
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
tr("Not tested yet."),
tr("Not tested yet."));

View File

@ -32,6 +32,9 @@
<property name="text">
<string>Application ID</string>
</property>
<property name="buddy">
<cstring>m_txtAppId</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
@ -42,6 +45,9 @@
<property name="text">
<string>Application key</string>
</property>
<property name="buddy">
<cstring>m_txtAppKey</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
@ -52,11 +58,24 @@
<property name="text">
<string>Redirect URL</string>
</property>
<property name="buddy">
<cstring>m_txtRedirectUrl</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="LineEditWithStatus" name="m_txtRedirectUrl" native="true"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="m_lblInfo">
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -67,6 +86,9 @@
<property name="text">
<string>Only download newest X messages per feed</string>
</property>
<property name="buddy">
<cstring>m_spinLimitMessages</cstring>
</property>
</widget>
</item>
<item row="0" column="1">

View File

@ -6,6 +6,7 @@
#define INOREADER_OAUTH_SCOPE "read write"
#define INOREADER_OAUTH_TOKEN_URL "https://www.inoreader.com/oauth2/token"
#define INOREADER_OAUTH_AUTH_URL "https://www.inoreader.com/oauth2/auth"
#define INOREADER_REG_API_URL "https://www.inoreader.com/developers/register-app"
#define INOREADER_OAUTH_CLI_ID "1000000604"
#define INOREADER_OAUTH_CLI_KEY "gsStoZ3aAoQJCgQxoFSuXkWI7Sly87yK"

View File

@ -6,6 +6,7 @@
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "network-web/oauth2service.h"
#include "network-web/webfactory.h"
#include "services/inoreader/definitions.h"
#include "services/inoreader/inoreaderserviceroot.h"
@ -15,6 +16,11 @@ FormEditInoreaderAccount::FormEditInoreaderAccount(QWidget* parent)
GuiUtilities::applyDialogProperties(*this, qApp->icons()->miscIcon(QSL("inoreader")));
GuiUtilities::setLabelAsNotice(*m_ui.m_lblInfo, true);
m_ui.m_lblInfo->setText(tr("Specified redirect URL must start with \"http://localhost\" and "
"must be configured in your OAuth \"application\".\n\n"
"It is highly recommended to create your own \"Application ID\"."));
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
tr("Not tested yet."),
tr("Not tested yet."));
@ -35,6 +41,7 @@ FormEditInoreaderAccount::FormEditInoreaderAccount(QWidget* parent)
connect(m_ui.m_btnTestSetup, &QPushButton::clicked, this, &FormEditInoreaderAccount::testSetup);
connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormEditInoreaderAccount::onClickedOk);
connect(m_ui.m_buttonBox, &QDialogButtonBox::rejected, this, &FormEditInoreaderAccount::onClickedCancel);
connect(m_ui.m_btnRegisterApi, &QPushButton::clicked, this, &FormEditInoreaderAccount::registerApi);
m_ui.m_spinLimitMessages->setValue(INOREADER_DEFAULT_BATCH_SIZE);
m_ui.m_spinLimitMessages->setMinimum(INOREADER_MIN_BATCH_SIZE);
@ -167,6 +174,10 @@ void FormEditInoreaderAccount::execForEdit(InoreaderServiceRoot* existing_root)
exec();
}
void FormEditInoreaderAccount::registerApi() {
qApp->web()->openUrlInExternalBrowser(INOREADER_REG_API_URL);
}
void FormEditInoreaderAccount::checkOAuthValue(const QString& value) {
auto* line_edit = qobject_cast<LineEditWithStatus*>(sender()->parent());

View File

@ -27,6 +27,7 @@ class FormEditInoreaderAccount : public QDialog {
void execForEdit(InoreaderServiceRoot* existing_root);
private slots:
void registerApi();
void testSetup();
void onClickedOk();
void onClickedCancel();

View File

@ -32,6 +32,9 @@
<property name="text">
<string>Application ID</string>
</property>
<property name="buddy">
<cstring>m_txtAppId</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
@ -42,6 +45,9 @@
<property name="text">
<string>Application key</string>
</property>
<property name="buddy">
<cstring>m_txtAppKey</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
@ -52,11 +58,31 @@
<property name="text">
<string>Redirect URL</string>
</property>
<property name="buddy">
<cstring>m_txtRedirectUrl</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="LineEditWithStatus" name="m_txtRedirectUrl" native="true"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="m_lblInfo">
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="m_btnRegisterApi">
<property name="text">
<string>Get my own Application ID</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -67,6 +93,9 @@
<property name="text">
<string>Only download newest X messages per feed</string>
</property>
<property name="buddy">
<cstring>m_spinLimitMessages</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
@ -148,6 +177,7 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>m_btnRegisterApi</tabstop>
<tabstop>m_spinLimitMessages</tabstop>
<tabstop>m_btnTestSetup</tabstop>
</tabstops>