From 0854e83ce48cb30b28bd05986970e506c1106e4e Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 12 Feb 2022 20:20:51 +0100 Subject: [PATCH] feat: implement MSA client id override Closes #11 --- launcher/Application.cpp | 10 ++++++++++ launcher/Application.h | 2 ++ launcher/minecraft/auth/steps/MSAStep.cpp | 2 +- launcher/ui/pages/global/AccountListPage.cpp | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 5e70c729..a3d6216e 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -1519,3 +1519,13 @@ QString Application::getJarsPath() } return m_jarsPath; } + +QString Application::getMSAClientID() +{ + QString clientIDOverride = m_settings->get("MSAClientIDOverride").toString(); + if (!clientIDOverride.isEmpty()) { + return clientIDOverride; + } + + return BuildConfig.MSA_CLIENT_ID; +} diff --git a/launcher/Application.h b/launcher/Application.h index c1cd8224..fb41d647 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -117,6 +117,8 @@ public: QString getJarsPath(); + QString getMSAClientID(); + /// this is the root of the 'installation'. Used for automatic updates const QString &root() { return m_rootPath; diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp index bc10aa4e..779aee43 100644 --- a/launcher/minecraft/auth/steps/MSAStep.cpp +++ b/launcher/minecraft/auth/steps/MSAStep.cpp @@ -14,7 +14,7 @@ using Activity = Katabasis::Activity; MSAStep::MSAStep(AccountData* data, Action action) : AuthStep(data), m_action(action) { OAuth2::Options opts; opts.scope = "XboxLive.signin offline_access"; - opts.clientIdentifier = BuildConfig.MSA_CLIENT_ID; + opts.clientIdentifier = APPLICATION->getMSAClientID(); opts.authorizationUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode"; opts.accessTokenUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token"; diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index 396d320f..ea310acd 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -73,7 +73,7 @@ AccountListPage::AccountListPage(QWidget *parent) updateButtonStates(); // Xbox authentication won't work without a client identifier, so disable the button if it is missing - ui->actionAddMicrosoft->setVisible(BuildConfig.MSA_CLIENT_ID.size() != 0); + ui->actionAddMicrosoft->setVisible(!APPLICATION->getMSAClientID().isEmpty()); } AccountListPage::~AccountListPage()