Commit b31930e6 authored by Krzysztof Nowicki's avatar Krzysztof Nowicki
Browse files

Retrieve OAuth2 tokens upon display of configuration dialog

This will allow use of already stored tokens in the configuration
dialog.
parent 173cf7c6
......@@ -116,13 +116,16 @@ EwsConfigDialog::EwsConfigDialog(EwsResource *parentResource, EwsClient &client,
connect(mSettings.data(), &EwsSettings::passwordRequestFinished, mUi->passwordEdit,
&KPasswordLineEdit::setPassword);
#ifdef HAVE_NETWORKAUTH
connect(mSettings.data(), &EwsSettings::tokensRequestFinished, this,
&EwsConfigDialog::tokensRequestFinished);
mUi->authOAuth2RadioButton->setEnabled(true);
const auto authMode = mSettings->authMode();
if (authMode == QStringLiteral("username-password")) {
mUi->authUsernameRadioButton->setChecked(true);
mSettings->requestPassword(false);
} else {
} else if (authMode == QStringLiteral("oauth2")) {
mUi->authOAuth2RadioButton->setChecked(true);
mSettings->requestTokens();
}
#else
mSettings->requestPassword(false);
......@@ -409,3 +412,12 @@ void EwsConfigDialog::userAgentChanged(int)
mUi->userAgentEdit->setText(data);
}
}
#ifdef HAVE_NETWORKAUTH
void EwsConfigDialog::tokensRequestFinished(const QString &accessToken, const QString &refreshToken)
{
qDebug() << "EwsConfigDialog: got tokens" << accessToken << refreshToken;
mAccessToken = accessToken;
mRefreshToken = refreshToken;
}
#endif
......@@ -60,7 +60,9 @@ private:
void userAgentChanged(int index);
QString fullUsername() const;
#ifdef HAVE_NETWORKAUTH
void tokensRequestFinished(const QString &accessToken, const QString &refreshToken);
#endif
EwsResource *mParentResource = nullptr;
KConfigDialogManager *mConfigManager = nullptr;
Ui::SetupServerView *mUi = nullptr;
......@@ -74,6 +76,10 @@ private:
EwsProgressDialog *mProgressDialog = nullptr;
EwsSubscriptionWidget *mSubWidget = nullptr;
QPointer<EwsSettings> mSettings;
#ifdef HAVE_NETWORKAUTH
QString mAccessToken;
QString mRefreshToken;
#endif
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment