Fix MSA login
This commit is contained in:
parent
d40b6d8eb3
commit
7f52d57454
@ -59,9 +59,10 @@ void MSADeviceCodeStep::perform()
|
|||||||
{
|
{
|
||||||
QUrlQuery data;
|
QUrlQuery data;
|
||||||
data.addQueryItem("client_id", m_clientId);
|
data.addQueryItem("client_id", m_clientId);
|
||||||
data.addQueryItem("scope", "XboxLive.SignIn XboxLive.offline_access");
|
data.addQueryItem("scope", "service::user.auth.xboxlive.com::MBI_SSL");
|
||||||
|
data.addQueryItem("response_type", "device_code");
|
||||||
auto payload = data.query(QUrl::FullyEncoded).toUtf8();
|
auto payload = data.query(QUrl::FullyEncoded).toUtf8();
|
||||||
QUrl url("https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode");
|
QUrl url("https://login.live.com/oauth20_connect.srf");
|
||||||
auto headers = QList<Net::HeaderPair>{
|
auto headers = QList<Net::HeaderPair>{
|
||||||
{ "Content-Type", "application/x-www-form-urlencoded" },
|
{ "Content-Type", "application/x-www-form-urlencoded" },
|
||||||
{ "Accept", "application/json" },
|
{ "Accept", "application/json" },
|
||||||
@ -175,8 +176,9 @@ void MSADeviceCodeStep::authenticateUser()
|
|||||||
data.addQueryItem("client_id", m_clientId);
|
data.addQueryItem("client_id", m_clientId);
|
||||||
data.addQueryItem("grant_type", "urn:ietf:params:oauth:grant-type:device_code");
|
data.addQueryItem("grant_type", "urn:ietf:params:oauth:grant-type:device_code");
|
||||||
data.addQueryItem("device_code", m_device_code);
|
data.addQueryItem("device_code", m_device_code);
|
||||||
|
data.addQueryItem("response_type", "device_code");
|
||||||
auto payload = data.query(QUrl::FullyEncoded).toUtf8();
|
auto payload = data.query(QUrl::FullyEncoded).toUtf8();
|
||||||
QUrl url("https://login.microsoftonline.com/consumers/oauth2/v2.0/token");
|
QUrl url("https://login.live.com/oauth20_token.srf");
|
||||||
auto headers = QList<Net::HeaderPair>{
|
auto headers = QList<Net::HeaderPair>{
|
||||||
{ "Content-Type", "application/x-www-form-urlencoded" },
|
{ "Content-Type", "application/x-www-form-urlencoded" },
|
||||||
{ "Accept", "application/json" },
|
{ "Accept", "application/json" },
|
||||||
@ -274,4 +276,4 @@ void MSADeviceCodeStep::authenticationFinished()
|
|||||||
m_data->msaToken.refresh_token = rsp.refresh_token;
|
m_data->msaToken.refresh_token = rsp.refresh_token;
|
||||||
m_data->msaToken.token = rsp.access_token;
|
m_data->msaToken.token = rsp.access_token;
|
||||||
emit finished(AccountTaskState::STATE_WORKING, tr("Got"));
|
emit finished(AccountTaskState::STATE_WORKING, tr("Got"));
|
||||||
}
|
}
|
||||||
|
@ -104,9 +104,16 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
|
|||||||
} else {
|
} else {
|
||||||
oauth2.setReplyHandler(new CustomOAuthOobReplyHandler(this));
|
oauth2.setReplyHandler(new CustomOAuthOobReplyHandler(this));
|
||||||
}
|
}
|
||||||
oauth2.setAuthorizationUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize"));
|
oauth2.setAuthorizationUrl(QUrl("https://login.live.com/oauth20_connect.srf"));
|
||||||
oauth2.setAccessTokenUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/token"));
|
oauth2.setAccessTokenUrl(QUrl("https://login.live.com/oauth20_token.srf"));
|
||||||
oauth2.setScope("XboxLive.SignIn XboxLive.offline_access");
|
const auto& scope = "service::user.auth.xboxlive.com::MBI_SSL";
|
||||||
|
oauth2.setScope(scope);
|
||||||
|
// QOAuth2AuthorizationCodeFlow doesn't pass a "scope" when refreshing access tokens, but Microsoft expects it.
|
||||||
|
oauth2.setModifyParametersFunction([](QAbstractOAuth::Stage stage, QMultiMap<QString, QVariant>* parameters) {
|
||||||
|
if (stage == QAbstractOAuth::Stage::RefreshingAccessToken) {
|
||||||
|
(*parameters).insert("scope", scope);
|
||||||
|
}
|
||||||
|
});
|
||||||
oauth2.setClientIdentifier(m_clientId);
|
oauth2.setClientIdentifier(m_clientId);
|
||||||
oauth2.setNetworkAccessManager(APPLICATION->network().get());
|
oauth2.setNetworkAccessManager(APPLICATION->network().get());
|
||||||
|
|
||||||
|
@ -145,11 +145,7 @@ void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, in
|
|||||||
ui->code->setText(code);
|
ui->code->setText(code);
|
||||||
auto isDefaultUrl = url == "https://www.microsoft.com/link";
|
auto isDefaultUrl = url == "https://www.microsoft.com/link";
|
||||||
ui->qr->setVisible(isDefaultUrl);
|
ui->qr->setVisible(isDefaultUrl);
|
||||||
if (isDefaultUrl) {
|
ui->qrMessage->setText(tr("Open %1 and enter the above code.").arg(linkString));
|
||||||
ui->qrMessage->setText(tr("Open %1 or scan the QR and enter the above code.").arg(linkString));
|
|
||||||
} else {
|
|
||||||
ui->qrMessage->setText(tr("Open %1 and enter the above code.").arg(linkString));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSALoginDialog::onDeviceFlowStatus(QString status)
|
void MSALoginDialog::onDeviceFlowStatus(QString status)
|
||||||
@ -172,4 +168,4 @@ MinecraftAccountPtr MSALoginDialog::newAccount(QWidget* parent)
|
|||||||
return dlg.m_account;
|
return dlg.m_account;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stackedWidget2">
|
<widget class="QStackedWidget" name="stackedWidget2">
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
@ -140,51 +143,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
|
||||||
<item>
|
|
||||||
<widget class="Line" name="line_3">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="orLabel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>16</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Or</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Line" name="line_4">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
|
Loading…
Reference in New Issue
Block a user